mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 21:19:21 +03:00
prettier --write
This commit is contained in:
parent
450528ff00
commit
8a0be3212d
164 changed files with 7053 additions and 9008 deletions
|
|
@ -1,28 +1,26 @@
|
|||
|
||||
import window from 'window';
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
import qr from 'qr';
|
||||
|
||||
import {Capa, StorageResultType} from 'Common/Enums';
|
||||
import {pString} from 'Common/Utils';
|
||||
import {i18n, trigger as translatorTrigger} from 'Common/Translator';
|
||||
import { Capa, StorageResultType } from 'Common/Enums';
|
||||
import { pString } from 'Common/Utils';
|
||||
import { i18n, trigger as translatorTrigger } from 'Common/Translator';
|
||||
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
import { getApp } from 'Helper/Apps/User';
|
||||
|
||||
import {popup, showScreenPopup} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
import { popup, showScreenPopup } from 'Knoin/Knoin';
|
||||
import { AbstractViewNext } from 'Knoin/AbstractViewNext';
|
||||
|
||||
@popup({
|
||||
name: 'View/Popup/TwoFactorConfiguration',
|
||||
templateID: 'PopupsTwoFactorConfiguration'
|
||||
})
|
||||
class TwoFactorConfigurationPopupView extends AbstractViewNext
|
||||
{
|
||||
class TwoFactorConfigurationPopupView extends AbstractViewNext {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
|
|
@ -50,26 +48,20 @@ class TwoFactorConfigurationPopupView extends AbstractViewNext
|
|||
read: this.viewEnable_,
|
||||
write: (value) => {
|
||||
value = !!value;
|
||||
if (value && this.twoFactorTested())
|
||||
{
|
||||
if (value && this.twoFactorTested()) {
|
||||
this.viewEnable_(value);
|
||||
Remote.enableTwoFactor((result, data) => {
|
||||
if (StorageResultType.Success !== result || !data || !data.Result)
|
||||
{
|
||||
if (StorageResultType.Success !== result || !data || !data.Result) {
|
||||
this.viewEnable_(false);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!value)
|
||||
{
|
||||
} else {
|
||||
if (!value) {
|
||||
this.viewEnable_(value);
|
||||
}
|
||||
|
||||
Remote.enableTwoFactor((result, data) => {
|
||||
if (StorageResultType.Success !== result || !data || !data.Result)
|
||||
{
|
||||
if (StorageResultType.Success !== result || !data || !data.Result) {
|
||||
this.viewEnable_(false);
|
||||
}
|
||||
}, false);
|
||||
|
|
@ -79,15 +71,17 @@ class TwoFactorConfigurationPopupView extends AbstractViewNext
|
|||
|
||||
this.viewTwoFactorEnableTooltip = ko.computed(() => {
|
||||
translatorTrigger();
|
||||
return this.twoFactorTested() || this.viewEnable_() ? '' :
|
||||
i18n('POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_TEST_BEFORE_DESC');
|
||||
return this.twoFactorTested() || this.viewEnable_()
|
||||
? ''
|
||||
: i18n('POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_TEST_BEFORE_DESC');
|
||||
});
|
||||
|
||||
this.viewTwoFactorStatus = ko.computed(() => {
|
||||
translatorTrigger();
|
||||
return i18n(this.twoFactorStatus() ?
|
||||
'POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_CONFIGURED_DESC' :
|
||||
'POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_NOT_CONFIGURED_DESC'
|
||||
return i18n(
|
||||
this.twoFactorStatus()
|
||||
? 'POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_CONFIGURED_DESC'
|
||||
: 'POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_NOT_CONFIGURED_DESC'
|
||||
);
|
||||
});
|
||||
|
||||
|
|
@ -144,24 +138,27 @@ class TwoFactorConfigurationPopupView extends AbstractViewNext
|
|||
}
|
||||
|
||||
onHide() {
|
||||
if (this.lock())
|
||||
{
|
||||
if (this.lock()) {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
getQr() {
|
||||
return 'otpauth://totp/' + window.encodeURIComponent(this.viewUser()) +
|
||||
'?secret=' + window.encodeURIComponent(this.viewSecret()) +
|
||||
'&issuer=' + window.encodeURIComponent('');
|
||||
return (
|
||||
'otpauth://totp/' +
|
||||
window.encodeURIComponent(this.viewUser()) +
|
||||
'?secret=' +
|
||||
window.encodeURIComponent(this.viewSecret()) +
|
||||
'&issuer=' +
|
||||
window.encodeURIComponent('')
|
||||
);
|
||||
}
|
||||
|
||||
onResult(sResult, oData) {
|
||||
this.processing(false);
|
||||
this.clearing(false);
|
||||
|
||||
if (StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
if (StorageResultType.Success === sResult && oData && oData.Result) {
|
||||
this.viewUser(pString(oData.Result.User));
|
||||
this.viewEnable_(!!oData.Result.Enable);
|
||||
this.twoFactorStatus(!!oData.Result.IsSet);
|
||||
|
|
@ -171,10 +168,8 @@ class TwoFactorConfigurationPopupView extends AbstractViewNext
|
|||
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()}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.viewUrl(qr.toDataURL({ level: 'M', size: 8, value: this.getQr() }));
|
||||
} else {
|
||||
this.viewUser('');
|
||||
this.viewEnable_(false);
|
||||
this.twoFactorStatus(false);
|
||||
|
|
@ -190,14 +185,11 @@ class TwoFactorConfigurationPopupView extends AbstractViewNext
|
|||
onShowSecretResult(result, data) {
|
||||
this.secreting(false);
|
||||
|
||||
if (StorageResultType.Success === result && data && data.Result)
|
||||
{
|
||||
if (StorageResultType.Success === result && data && data.Result) {
|
||||
this.viewSecret(pString(data.Result.Secret));
|
||||
this.viewUrlTitle(pString(data.Result.UrlTitle));
|
||||
this.viewUrl(qr.toDataURL({level: 'M', size: 6, value: this.getQr()}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.viewUrl(qr.toDataURL({ level: 'M', size: 6, value: this.getQr() }));
|
||||
} else {
|
||||
this.viewSecret('');
|
||||
this.viewUrlTitle('');
|
||||
this.viewUrl('');
|
||||
|
|
@ -205,12 +197,11 @@ class TwoFactorConfigurationPopupView extends AbstractViewNext
|
|||
}
|
||||
|
||||
onBuild() {
|
||||
if (this.capaTwoFactor)
|
||||
{
|
||||
if (this.capaTwoFactor) {
|
||||
this.processing(true);
|
||||
Remote.getTwoFactor(this.onResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {TwoFactorConfigurationPopupView, TwoFactorConfigurationPopupView as default};
|
||||
export { TwoFactorConfigurationPopupView, TwoFactorConfigurationPopupView as default };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue