mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-11 00:14:50 +03:00
2-Step Verification (Google Authenticator)
Small fixes
This commit is contained in:
parent
cae0cc2f77
commit
419b47a81e
51 changed files with 1747 additions and 419 deletions
|
|
@ -15,6 +15,11 @@ function LoginViewModel()
|
|||
this.password = ko.observable('');
|
||||
this.signMe = ko.observable(false);
|
||||
|
||||
this.additionalCode = ko.observable('');
|
||||
this.additionalCode.error = ko.observable(false);
|
||||
this.additionalCode.focused = ko.observable(false);
|
||||
this.additionalCode.visibility = ko.observable(false);
|
||||
|
||||
this.logoImg = Utils.trim(RL.settingsGet('LoginLogo'));
|
||||
this.loginDescription = Utils.trim(RL.settingsGet('LoginDescription'));
|
||||
this.logoCss = Utils.trim(RL.settingsGet('LoginCss'));
|
||||
|
|
@ -29,6 +34,8 @@ function LoginViewModel()
|
|||
|
||||
this.email.subscribe(function () {
|
||||
this.emailError(false);
|
||||
this.additionalCode('');
|
||||
this.additionalCode.visibility(false);
|
||||
}, this);
|
||||
|
||||
this.login.subscribe(function () {
|
||||
|
|
@ -39,6 +46,14 @@ function LoginViewModel()
|
|||
this.passwordError(false);
|
||||
}, this);
|
||||
|
||||
this.additionalCode.subscribe(function () {
|
||||
this.additionalCode.error(false);
|
||||
}, this);
|
||||
|
||||
this.additionalCode.visibility.subscribe(function () {
|
||||
this.additionalCode.error(false);
|
||||
}, this);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
|
|
@ -68,7 +83,12 @@ function LoginViewModel()
|
|||
this.emailError('' === Utils.trim(this.email()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
|
||||
if (this.emailError() || this.passwordError())
|
||||
if (this.additionalCode.visibility())
|
||||
{
|
||||
this.additionalCode.error('' === Utils.trim(this.additionalCode()));
|
||||
}
|
||||
|
||||
if (this.emailError() || this.passwordError() || this.additionalCode.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -81,12 +101,28 @@ function LoginViewModel()
|
|||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
RL.loginAndLogoutReload();
|
||||
if (oData.TwoFactorAuth)
|
||||
{
|
||||
this.additionalCode('');
|
||||
this.additionalCode.visibility(true);
|
||||
this.additionalCode.focused(true);
|
||||
|
||||
this.submitRequest(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
RL.loginAndLogoutReload();
|
||||
}
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Utils.getNotification(oData.ErrorCode));
|
||||
|
||||
if ('' === this.submitError())
|
||||
{
|
||||
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -100,7 +136,8 @@ function LoginViewModel()
|
|||
}
|
||||
|
||||
}, this), this.email(), this.login(), this.password(), !!this.signMe(),
|
||||
this.bSendLanguage ? this.mainLanguage() : '');
|
||||
this.bSendLanguage ? this.mainLanguage() : '',
|
||||
this.additionalCode.visibility() ? this.additionalCode() : '');
|
||||
|
||||
return true;
|
||||
|
||||
|
|
|
|||
|
|
@ -929,12 +929,12 @@ PopupsComposeViewModel.prototype.onBuild = function ()
|
|||
|
||||
if (oEvent && self.modalVisibility() && RL.data().useKeyboardShortcuts())
|
||||
{
|
||||
if (self.bAllowCtrlS && oEvent.ctrlKey && Enums.EventKeyCode.S === oEvent.keyCode)
|
||||
if (self.bAllowCtrlS && oEvent.ctrlKey && !oEvent.shiftKey && !oEvent.altKey && Enums.EventKeyCode.S === oEvent.keyCode)
|
||||
{
|
||||
self.saveCommand();
|
||||
bResult = false;
|
||||
}
|
||||
else if (oEvent.ctrlKey && Enums.EventKeyCode.Enter === oEvent.keyCode)
|
||||
else if (oEvent.ctrlKey && !oEvent.shiftKey && !oEvent.altKey && Enums.EventKeyCode.Enter === oEvent.keyCode)
|
||||
{
|
||||
self.sendCommand();
|
||||
bResult = false;
|
||||
|
|
|
|||
55
dev/ViewModels/PopupsTwoFactorTestViewModel.js
Normal file
55
dev/ViewModels/PopupsTwoFactorTestViewModel.js
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsTwoFactorTestViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsTwoFactorTest');
|
||||
|
||||
var self = this;
|
||||
|
||||
this.code = ko.observable('');
|
||||
this.code.focused = ko.observable(false);
|
||||
this.code.status = ko.observable(null);
|
||||
|
||||
this.testing = ko.observable(false);
|
||||
|
||||
// commands
|
||||
this.testCode = Utils.createCommand(this, function () {
|
||||
|
||||
this.testing(true);
|
||||
RL.remote().testTwoFactor(function (sResult, oData) {
|
||||
|
||||
self.testing(false);
|
||||
self.code.status(Enums.StorageResultType.Success === sResult && oData && oData.Result ? true : false);
|
||||
|
||||
}, this.code());
|
||||
|
||||
}, function () {
|
||||
return '' !== this.code() && !this.testing();
|
||||
});
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsTwoFactorTestViewModel', PopupsTwoFactorTestViewModel);
|
||||
|
||||
PopupsTwoFactorTestViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.code('');
|
||||
this.code.focused(false);
|
||||
this.code.status(null);
|
||||
this.testing(false);
|
||||
};
|
||||
|
||||
PopupsTwoFactorTestViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
PopupsTwoFactorTestViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
this.code.focused(true);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue