Two factor authentication : TOTP #5

Merged
pierre merged 22 commits from twofactors into master 2022-04-20 07:40:51 +00:00
2 changed files with 4 additions and 4 deletions
Showing only changes of commit b5a2f1abcb - Show all commits

View File

@ -55,6 +55,6 @@ impl AppConfig {
}
pub fn domain_name(&self) -> &str {
self.website_origin.split('/').skip(2).next().unwrap_or(APP_NAME)
self.website_origin.split('/').nth(2).unwrap_or(APP_NAME)
}
}

View File

@ -38,10 +38,10 @@ impl TotpKey {
pub fn url_for_user(&self, u: &User, conf: &AppConfig) -> String {
format!(
"otpauth://totp/{}:{}?secret={}&issuer={}&algorithm=SHA1&digits={}&period={}",
urlencoding::encode(&conf.domain_name()),
urlencoding::encode(conf.domain_name()),
urlencoding::encode(&u.username),
self.encoded,
urlencoding::encode(&conf.domain_name()),
urlencoding::encode(conf.domain_name()),
NUM_DIGITS,
PERIOD,
)
@ -63,7 +63,7 @@ impl TotpKey {
/// Get current code
pub fn current_code(&self) -> Res<String> {
self.get_code_at(|| time())
self.get_code_at(time)
}
/// Get previous code