mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 12:39:20 +03:00
Add support for global 2FA enforcement #349
This commit is contained in:
parent
375f715b78
commit
8b3cfc7a67
15 changed files with 85 additions and 54 deletions
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
(rl => {
|
||||
|
||||
rl && addEventListener('rl-view-model', e => {
|
||||
addEventListener('rl-view-model', e => {
|
||||
if (e.detail && 'Login' === e.detail.viewModelTemplateID) {
|
||||
const container = e.detail.viewModelDom.querySelector('#plugin-Login-BottomControlGroup'),
|
||||
placeholder = 'LOGIN/LABEL_TWO_FACTOR_CODE';
|
||||
placeholder = 'PLUGIN_2FA/LABEL_TWO_FACTOR_CODE';
|
||||
if (container) {
|
||||
container.prepend(Element.fromHTML('<div class="controls">'
|
||||
+ '<span class="fontastic">⏱</span>'
|
||||
|
|
@ -18,4 +18,15 @@
|
|||
}
|
||||
});
|
||||
|
||||
// https://github.com/the-djmaze/snappymail/issues/349
|
||||
let code;
|
||||
addEventListener('sm-user-login', e => {
|
||||
code = e.detail.get('totp_code');
|
||||
});
|
||||
addEventListener('sm-user-login-response', e => {
|
||||
if (e.detail && !e.detail.error && rl.settings.get('RequireTwoFactor') && !code) {
|
||||
document.location.hash = '#/settings/two-factor-auth';
|
||||
}
|
||||
});
|
||||
|
||||
})(window.rl);
|
||||
|
|
|
|||
|
|
@ -70,12 +70,12 @@ class TwoFactorAuthSettings
|
|||
// translatorTrigger();
|
||||
return this.twoFactorTested() || this.viewEnable_()
|
||||
? ''
|
||||
: rl.i18n('POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_TEST_BEFORE_DESC');
|
||||
: rl.i18n('PLUGIN_2FA/TWO_FACTOR_SECRET_TEST_BEFORE_DESC');
|
||||
},
|
||||
|
||||
viewTwoFactorStatus: () => {
|
||||
// translatorTrigger();
|
||||
return rl.i18n('POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_'
|
||||
return rl.i18n('PLUGIN_2FA/TWO_FACTOR_SECRET_'
|
||||
+ (this.twoFactorStatus() ? '' : 'NOT_')
|
||||
+ 'CONFIGURED_DESC'
|
||||
);
|
||||
|
|
@ -202,7 +202,7 @@ class TwoFactorAuthTestPopupView extends rl.pluginPopupView {
|
|||
rl.addSettingsViewModel(
|
||||
TwoFactorAuthSettings,
|
||||
'TwoFactorAuthSettings',
|
||||
'POPUPS_TWO_FACTOR_CFG/LEGEND_TWO_FACTOR_AUTH',
|
||||
'PLUGIN_2FA/LEGEND_TWO_FACTOR_AUTH',
|
||||
'two-factor-auth'
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue