mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
Get 2FA plugin somesort of working
This commit is contained in:
parent
868f7a4b0a
commit
2d1f99a8ce
12 changed files with 151 additions and 216 deletions
23
plugins/two-factor-auth/js/TwoFactorAuthLogin.js
Normal file
23
plugins/two-factor-auth/js/TwoFactorAuthLogin.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
(rl => {
|
||||
|
||||
rl && addEventListener('rl-view-model', e => {
|
||||
if (e.detail && 'Login' === e.detail.viewModelTemplateID) {
|
||||
const container = e.detail.viewModelDom.querySelector('#plugin-Login-BottomControlGroup'),
|
||||
placeholder = 'LOGIN/LABEL_VERIFICATION_CODE';
|
||||
if (container) {
|
||||
container.append(Element.fromHTML('<div class="controls">'
|
||||
+ '<div class="input-append">'
|
||||
+ '<input name="totp_code" type="text" class="input-block-level inputIcon"'
|
||||
+ ' pattern="[0-9]*" inputmode="numeric"'
|
||||
+ ' autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false"'
|
||||
+ ' data-bind="textInput: totp, disable: submitRequest" data-i18n="[placeholder]'+placeholder
|
||||
+ '" placeholder="'+rl.i18n(placeholder)+'">'
|
||||
+ '<i class="add-on fontastic">🔑</i>'
|
||||
+ '</div>'
|
||||
+ '</div>'));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
})(window.rl);
|
||||
|
|
@ -5,11 +5,6 @@ import { trigger as translatorTrigger } from 'Common/Translator';
|
|||
(rl => { if (rl) {
|
||||
|
||||
const
|
||||
Capa = {
|
||||
TwoFactor: 'TWO_FACTOR',
|
||||
TwoFactorForce: 'TWO_FACTOR_FORCE',
|
||||
},
|
||||
|
||||
pString = value => null != value ? '' + value : '',
|
||||
|
||||
Remote = new class {
|
||||
|
|
@ -56,10 +51,8 @@ class TwoFactorAuthSettings
|
|||
|
||||
this.viewEnable_ = ko.observable(false);
|
||||
|
||||
this.capaTwoFactor = rl.settings.capa(Capa.TwoFactor);
|
||||
|
||||
const fn = iError => iError && this.viewEnable_(false);
|
||||
this.addComputables({
|
||||
Object.entries({
|
||||
viewEnable: {
|
||||
read: this.viewEnable_,
|
||||
write: (value) => {
|
||||
|
|
@ -92,12 +85,16 @@ class TwoFactorAuthSettings
|
|||
},
|
||||
|
||||
twoFactorAllowedEnable: () => this.viewEnable() || this.twoFactorTested()
|
||||
});
|
||||
}).forEach(([key, fn]) => this[key] = ko.computed(fn));
|
||||
|
||||
this.onResult = this.onResult.bind(this);
|
||||
this.onShowSecretResult = this.onShowSecretResult.bind(this);
|
||||
}
|
||||
|
||||
configureTwoFactor() {
|
||||
// showScreenPopup(require('View/Popup/TwoFactorConfiguration'));
|
||||
}
|
||||
|
||||
showSecret() {
|
||||
this.secreting(true);
|
||||
rl.pluginRemoteRequest(this.onShowSecretResult, 'ShowTwoFactorSecret');
|
||||
|
|
@ -180,7 +177,7 @@ class TwoFactorAuthSettings
|
|||
this.viewBackupCodes(pString(oData.Result.BackupCodes).replace(/[\s]+/g, ' '));
|
||||
|
||||
this.viewUrlTitle(pString(oData.Result.UrlTitle));
|
||||
this.viewUrl(qr.toDataURL({ level: 'M', size: 8, value: this.getQr() }));
|
||||
this.viewUrl(null/*qr.toDataURL({ level: 'M', size: 8, value: this.getQr() })*/);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -194,15 +191,13 @@ class TwoFactorAuthSettings
|
|||
} else {
|
||||
this.viewSecret(pString(data.Result.Secret));
|
||||
this.viewUrlTitle(pString(data.Result.UrlTitle));
|
||||
this.viewUrl(qr.toDataURL({ level: 'M', size: 6, value: this.getQr() }));
|
||||
this.viewUrl(null/*qr.toDataURL({ level: 'M', size: 6, value: this.getQr() })*/);
|
||||
}
|
||||
}
|
||||
|
||||
onBuild() {
|
||||
if (this.capaTwoFactor) {
|
||||
this.processing(true);
|
||||
rl.pluginRemoteRequest(this.onResult, 'GetTwoFactorInfo');
|
||||
}
|
||||
this.processing(true);
|
||||
rl.pluginRemoteRequest(this.onResult, 'GetTwoFactorInfo');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue