Authentication using TOPT code is working

This commit is contained in:
2022-04-20 09:35:57 +02:00
parent 958f6eaabf
commit 1e401a0b10
2 changed files with 33 additions and 6 deletions

View File

@ -12,7 +12,8 @@ pub struct FactorID(pub String);
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub enum TwoFactorType {
TOTP(TotpKey)
TOTP(TotpKey),
_OTHER,
}
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
@ -25,14 +26,16 @@ pub struct TwoFactor {
impl TwoFactor {
pub fn type_str(&self) -> &'static str {
match self.kind {
TwoFactorType::TOTP(_) => "Authenticator app"
TwoFactorType::TOTP(_) => "Authenticator app",
_ => unimplemented!()
}
}
pub fn login_url(&self, redirect_uri: &LoginRedirect) -> String {
match self.kind {
TwoFactorType::TOTP(_) => format!("/2fa_otp?id={}&redirect={}",
self.id.0, redirect_uri.get_encoded())
self.id.0, redirect_uri.get_encoded()),
_ => unimplemented!()
}
}
}