From 700e084101fe789433b48f17e555121f39c79bb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Fri, 25 Jan 2019 18:50:57 +0100 Subject: [PATCH] Add 2FA icon to admin panel --- src/api/identity.rs | 5 +---- src/db/models/two_factor.rs | 1 + src/mail.rs | 2 +- src/static/templates/admin/page.hbs | 3 +++ 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/api/identity.rs b/src/api/identity.rs index b6092a31..8638796b 100644 --- a/src/api/identity.rs +++ b/src/api/identity.rs @@ -151,10 +151,7 @@ fn twofactor_auth( device: &mut Device, conn: &DbConn, ) -> ApiResult> { - let twofactors_raw = TwoFactor::find_by_user(user_uuid, conn); - // Remove u2f challenge twofactors (impl detail) - let twofactors: Vec<_> = twofactors_raw.iter().filter(|tf| tf.type_ < 1000).collect(); - + let twofactors = TwoFactor::find_by_user(user_uuid, conn); let providers: Vec<_> = twofactors.iter().map(|tf| tf.type_).collect(); // No twofactor token if twofactor is disabled diff --git a/src/db/models/two_factor.rs b/src/db/models/two_factor.rs index fd1d2c7b..1086f0e8 100644 --- a/src/db/models/two_factor.rs +++ b/src/db/models/two_factor.rs @@ -100,6 +100,7 @@ impl TwoFactor { pub fn find_by_user(user_uuid: &str, conn: &DbConn) -> Vec { twofactor::table .filter(twofactor::user_uuid.eq(user_uuid)) + .filter(twofactor::type_.lt(1000)) // Filter implementation types .load::(&**conn) .expect("Error loading twofactor") } diff --git a/src/mail.rs b/src/mail.rs index 1d9e45ff..0920f9db 100644 --- a/src/mail.rs +++ b/src/mail.rs @@ -125,7 +125,7 @@ pub fn send_invite_confirmed(address: &str, org_name: &str, config: &MailConfig) fn send_email(address: &str, subject: &str, body: &str, config: &MailConfig) -> EmptyResult { let email = EmailBuilder::new() .to(address) - .from((config.smtp_from.clone(), config.smtp_from_name.clone())) + .from((config.smtp_from.as_str(), config.smtp_from_name.as_str())) .subject(subject) .header(("Content-Type", "text/html")) .body(body) diff --git a/src/static/templates/admin/page.hbs b/src/static/templates/admin/page.hbs index 538eda8e..5d1d9c71 100644 --- a/src/static/templates/admin/page.hbs +++ b/src/static/templates/admin/page.hbs @@ -10,6 +10,9 @@
{{Name}} + {{#if TwoFactorEnabled}} + 2FA + {{/if}} {{Email}}