Add a page to choose second factor
This commit is contained in:
@ -9,7 +9,7 @@ pub enum SessionStatus {
|
||||
Invalid,
|
||||
SignedIn,
|
||||
NeedNewPassword,
|
||||
NeedMFA,
|
||||
Need2FA,
|
||||
}
|
||||
|
||||
impl Default for SessionStatus {
|
||||
@ -89,6 +89,12 @@ impl<'a> SessionIdentity<'a> {
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn need_2fa_auth(&self) -> bool {
|
||||
self.get_session_data()
|
||||
.map(|s| s.status == SessionStatus::Need2FA)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn is_admin(&self) -> bool {
|
||||
self.get_session_data().unwrap_or_default().is_admin
|
||||
}
|
||||
|
@ -26,6 +26,13 @@ impl TwoFactor {
|
||||
TwoFactorType::TOTP(_) => "Authenticator app"
|
||||
}
|
||||
}
|
||||
|
||||
pub fn login_url(&self, redirect_uri: &str) -> String {
|
||||
match self.kind {
|
||||
TwoFactorType::TOTP(_) => format!("/2fa_totp?id={}&redirect_uri={}",
|
||||
self.id.0, redirect_uri)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
|
Reference in New Issue
Block a user