snappymail/plugins/two-factor-auth/js/TwoFactorAuthLogin.js
google-labs-jules[bot] 60696d03fd Update repository URLs to nextgen-networks while preserving deep links
Replaced bare references to the-djmaze/snappymail with nextgen-networks/snappymail/
and updated .git URLs to the new organization.

Per user request:
- README files are excluded.
- URLs with a trailing slash (e.g. issues, pull requests, releases) are
  left pointing to the original repository to preserve historical context.
- Bare web URLs now include the requested trailing slash.
- Existing nextgen-networks bare URLs were updated to include the trailing slash.

Co-authored-by: nextgen-networks <21206978+nextgen-networks@users.noreply.github.com>
2026-02-20 11:43:13 +00:00

36 lines
1.1 KiB
JavaScript

(rl => {
const
forceTOTP = () => {
if (rl.settings.get('SetupTwoFactor')) {
setTimeout(() => document.location.hash = '#/settings/two-factor-auth', 50);
}
};
addEventListener('rl-view-model', e => {
if ('Login' === e.detail.viewModelTemplateID) {
const container = e.detail.viewModelDom.querySelector('#plugin-Login-BottomControlGroup'),
placeholder = 'PLUGIN_2FA/LABEL_TWO_FACTOR_CODE';
if (container) {
container.prepend(Element.fromHTML('<div class="controls">'
+ '<span class="fontastic">⏱</span>'
+ '<input name="totp_code" type="text" class="input-block-level"'
+ ' pattern="[0-9]*" inputmode="numeric"'
+ ' autocomplete="one-time-code" autocorrect="off" autocapitalize="none"'
+ ' data-bind="textInput: totp, disable: submitRequest" data-i18n="[placeholder]'+placeholder
+ '" placeholder="'+rl.i18n(placeholder)+'">'
+ '</div>'));
}
}
});
// https://github.com/the-djmaze/snappymail/issues/349
addEventListener('sm-show-screen', e => {
if (!e.detail.startsWith('settings') && rl.settings.get('SetupTwoFactor')) {
e.preventDefault();
forceTOTP();
}
});
})(window.rl);