{
bail!("failed to verify TOTP challenge");
}
- config
- .add_totp(userid, description, totp)
- .map(TfaUpdateInfo::id)
+ Ok(TfaUpdateInfo::id(config.add_totp(
+ userid,
+ description,
+ totp,
+ )))
}
fn add_yubico(
value: Option<String>,
) -> Result<TfaUpdateInfo, Error> {
let key = value.ok_or_else(|| format_err!("missing 'value' parameter for 'yubico' entry"))?;
- config
- .add_yubico(userid, description, key)
- .map(TfaUpdateInfo::id)
+ Ok(TfaUpdateInfo::id(config.add_yubico(
+ userid,
+ description,
+ key,
+ )))
}
fn add_u2f<A: OpenUserChallengeData>(
///
/// Unlike U2F/WA, this does not require a challenge/response. The user can choose their secret
/// themselves.
- pub fn add_totp(
- &mut self,
- userid: &str,
- description: String,
- value: Totp,
- ) -> Result<String, Error> {
- Ok(self
- .users
+ pub fn add_totp(&mut self, userid: &str, description: String, value: Totp) -> String {
+ self.users
.entry(userid.to_owned())
.or_default()
- .add_totp(description, value))
+ .add_totp(description, value)
}
/// Add a Yubico key to a user.
///
/// Unlike U2F/WA, this does not require a challenge/response. The user can choose their secret
/// themselves.
- pub fn add_yubico(
- &mut self,
- userid: &str,
- description: String,
- key: String,
- ) -> Result<String, Error> {
- Ok(self
- .users
+ pub fn add_yubico(&mut self, userid: &str, description: String, key: String) -> String {
+ self.users
.entry(userid.to_owned())
.or_default()
- .add_yubico(description, key))
+ .add_yubico(description, key)
}
/// Add a new set of recovery keys. There can only be 1 set of keys at a time.