Display form to enter OTP code

This commit is contained in:
2022-04-19 19:24:07 +02:00
parent c1677071fc
commit ce7118ff81
4 changed files with 75 additions and 2 deletions

View File

@ -29,7 +29,7 @@ impl TwoFactor {
pub fn login_url(&self, redirect_uri: &str) -> String {
match self.kind {
TwoFactorType::TOTP(_) => format!("/2fa_totp?id={}&redirect_uri={}",
TwoFactorType::TOTP(_) => format!("/2fa_otp?id={}&redirect_uri={}",
self.id.0, redirect_uri)
}
}
@ -83,6 +83,10 @@ impl User {
pub fn remove_factor(&mut self, factor_id: FactorID) {
self.two_factor.retain(|f| f.id != factor_id);
}
pub fn find_factor(&self, factor_id: &FactorID) -> Option<&TwoFactor> {
self.two_factor.iter().find(|f| f.id.eq(&factor_id))
}
}
impl PartialEq for User {