Two factor authentication : TOTP #5
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user