snappymail/dev/Settings/ChangePassword.js
RainLoop Team 4cc2207513 Uploading and preparing the repository to the dev version.
Original unminified source code (dev folder - js, css, less) (fixes #6)
Grunt build system
Multiple identities correction (fixes #9)
Compose html editor (fixes #12)
New general settings - Loading Description
New warning about default admin password
Split general and login screen settings
2013-11-16 02:21:12 +04:00

66 lines
1.7 KiB
JavaScript

/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsChangePasswordScreen()
{
this.changeProcess = ko.observable(false);
this.passwordUpdateError = ko.observable(false);
this.passwordUpdateSuccess = ko.observable(false);
this.currentPassword = ko.observable('');
this.newPassword = ko.observable('');
this.currentPassword.subscribe(function () {
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
}, this);
this.newPassword.subscribe(function () {
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
}, this);
this.saveNewPasswordCommand = Utils.createCommand(this, function () {
this.changeProcess(true);
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
RL.remote().changePassword(this.onChangePasswordResponse, this.currentPassword(), this.newPassword());
}, function () {
return !this.changeProcess() && '' !== this.currentPassword() && '' !== this.newPassword();
});
this.onChangePasswordResponse = _.bind(this.onChangePasswordResponse, this);
}
Utils.addSettingsViewModel(SettingsChangePasswordScreen, 'SettingsChangePassword', 'SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME', 'change-password');
SettingsChangePasswordScreen.prototype.onHide = function ()
{
this.changeProcess(false);
this.currentPassword('');
this.newPassword('');
};
SettingsChangePasswordScreen.prototype.onChangePasswordResponse = function (sResult, oData)
{
this.changeProcess(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
this.currentPassword('');
this.newPassword('');
this.passwordUpdateSuccess(true);
}
else
{
this.passwordUpdateError(true);
}
};