From ee7837d022488986ebd17cc1aa39cd11da9f738b Mon Sep 17 00:00:00 2001 From: vpl Date: Mon, 19 Aug 2019 22:14:00 +0200 Subject: [PATCH] Add option to require new device emails --- src/api/identity.rs | 4 ++++ src/config.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/api/identity.rs b/src/api/identity.rs index fe40dcd2..1990e35b 100644 --- a/src/api/identity.rs +++ b/src/api/identity.rs @@ -108,6 +108,10 @@ fn _password_login(data: ConnectData, conn: DbConn, ip: ClientIp) -> JsonResult if CONFIG.mail_enabled() && new_device { if let Err(e) = mail::send_new_device_logged_in(&user.email, &ip.ip.to_string(), &device.updated_at, &device.name) { error!("Error sending new device email: {:#?}", e); + + if CONFIG.require_device_email() { + err!("Could not send login notification email. Please contact your administrator.") + } } } diff --git a/src/config.rs b/src/config.rs index 85d97511..eaf8127c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -269,6 +269,10 @@ make_config! { /// Note that the checkbox would still be present, but ignored. disable_2fa_remember: bool, true, def, false; + /// Require new device emails |> When a user logs in an email is required to be sent. + /// If sending the email fails the login attempt will fail. + require_device_email: bool, true, def, false; + /// Reload templates (Dev) |> When this is set to true, the templates get reloaded with every request. /// ONLY use this during development, as it can slow down the server reload_templates: bool, true, def, false;