mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-15 12:15:20 +08:00
56 lines
1.1 KiB
JavaScript
56 lines
1.1 KiB
JavaScript
import { StorageResultType } from 'Common/Enums';
|
|
|
|
import Remote from 'Remote/User/Fetch';
|
|
|
|
import { command } from 'Knoin/Knoin';
|
|
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
|
|
|
class TwoFactorTestPopupView extends AbstractViewPopup {
|
|
constructor() {
|
|
super('TwoFactorTest');
|
|
|
|
this.addObservables({
|
|
code: '',
|
|
codeFocused: false,
|
|
codeStatus: null,
|
|
|
|
testing: false
|
|
});
|
|
|
|
this.koTestedTrigger = null;
|
|
}
|
|
|
|
@command((self) => self.code() && !self.testing())
|
|
testCodeCommand() {
|
|
this.testing(true);
|
|
Remote.testTwoFactor((result, data) => {
|
|
this.testing(false);
|
|
this.codeStatus(StorageResultType.Success === result && data && !!data.Result);
|
|
|
|
if (this.koTestedTrigger && this.codeStatus()) {
|
|
this.koTestedTrigger(true);
|
|
}
|
|
}, this.code());
|
|
}
|
|
|
|
clearPopup() {
|
|
this.code('');
|
|
this.codeFocused(false);
|
|
this.codeStatus(null);
|
|
this.testing(false);
|
|
|
|
this.koTestedTrigger = null;
|
|
}
|
|
|
|
onShow(koTestedTrigger) {
|
|
this.clearPopup();
|
|
|
|
this.koTestedTrigger = koTestedTrigger;
|
|
}
|
|
|
|
onShowWithDelay() {
|
|
this.codeFocused(true);
|
|
}
|
|
}
|
|
|
|
export { TwoFactorTestPopupView, TwoFactorTestPopupView as default };
|