2015-01-23 13:09:30 +00:00
|
|
|
|
2021-03-31 10:18:25 +00:00
|
|
|
Hedera.Conf = new Class({
|
2016-09-26 09:28:47 +00:00
|
|
|
Extends: Hedera.Form
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2021-03-31 10:18:25 +00:00
|
|
|
,activate: function() {
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.userModel.setInfo('c', 'myClient', 'hedera');
|
|
|
|
this.$.userModel.setInfo('u', 'myUser', 'account');
|
2021-03-31 10:18:25 +00:00
|
|
|
|
|
|
|
if (this.hash.get('verificationToken'))
|
|
|
|
this.onPassChangeClick();
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
2016-10-11 14:45:10 +00:00
|
|
|
|
2021-03-31 10:18:25 +00:00
|
|
|
,onPassChangeClick: function() {
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.oldPassword.value = '';
|
|
|
|
this.$.newPassword.value = '';
|
|
|
|
this.$.repeatPassword.value = '';
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2021-03-31 10:18:25 +00:00
|
|
|
var verificationToken = this.hash.get('verificationToken');
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.oldPassword.style.display = verificationToken ? 'none' : 'block';
|
|
|
|
this.$.changePassword.show();
|
2016-10-11 14:45:10 +00:00
|
|
|
|
2021-03-31 10:18:25 +00:00
|
|
|
if (verificationToken)
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.newPassword.focus();
|
2016-10-14 10:58:35 +00:00
|
|
|
else
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.oldPassword.focus();
|
2016-10-11 14:45:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-31 10:18:25 +00:00
|
|
|
,onPassModifyClick: function() {
|
2016-10-11 14:45:10 +00:00
|
|
|
try {
|
2022-05-28 01:18:06 +00:00
|
|
|
var oldPassword = this.$.oldPassword.value;
|
|
|
|
var newPassword = this.$.newPassword.value;
|
|
|
|
var repeatedPassword = this.$.repeatPassword.value;
|
2016-10-11 14:45:10 +00:00
|
|
|
|
|
|
|
if (newPassword == '' && repeatedPassword == '')
|
2021-03-31 10:18:25 +00:00
|
|
|
throw new Error(_('Passwords empty'));
|
2016-10-11 14:45:10 +00:00
|
|
|
if (newPassword !== repeatedPassword)
|
2021-03-31 10:18:25 +00:00
|
|
|
throw new Error(_('Passwords doesn\'t match'));
|
2016-10-11 14:45:10 +00:00
|
|
|
|
2021-03-31 10:18:25 +00:00
|
|
|
var verificationToken = this.hash.get('verificationToken');
|
|
|
|
var params = {newPassword: newPassword};
|
|
|
|
|
|
|
|
if (verificationToken) {
|
|
|
|
params.verificationToken = verificationToken;
|
|
|
|
this.conn.send('core/restore-password', params,
|
|
|
|
this._onPassChange.bind(this));
|
|
|
|
} else {
|
2022-05-05 13:56:17 +00:00
|
|
|
let userId = this.gui.user.id;
|
2021-03-31 10:18:25 +00:00
|
|
|
params.oldPassword = oldPassword;
|
2022-05-05 13:56:17 +00:00
|
|
|
this.conn.lbSend('PATCH',
|
|
|
|
`Accounts/${userId}/changePassword`, params,
|
|
|
|
this._onPassChange.bind(this)
|
|
|
|
);
|
2021-03-31 10:18:25 +00:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
Htk.Toast.showError(e.message);
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
}
|
2022-05-05 13:56:17 +00:00
|
|
|
|
2021-03-31 10:18:25 +00:00
|
|
|
,_onPassChange: function(json, error) {
|
2022-05-05 13:56:17 +00:00
|
|
|
if (!error) {
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.changePassword.hide();
|
2021-03-31 10:18:25 +00:00
|
|
|
this.hash.unset('verificationToken');
|
|
|
|
Htk.Toast.showMessage(_('Password changed!'));
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.userForm.refresh();
|
2021-03-31 10:18:25 +00:00
|
|
|
} else {
|
|
|
|
Htk.Toast.showError(error.message);
|
|
|
|
|
|
|
|
if (this.hash.get('verificationToken'))
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.newPassword.select();
|
2021-03-31 10:18:25 +00:00
|
|
|
else
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.oldPassword.select();
|
2016-10-11 14:45:10 +00:00
|
|
|
}
|
2015-03-06 23:33:54 +00:00
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2021-03-31 10:18:25 +00:00
|
|
|
,onPassInfoClick: function() {
|
2022-05-28 01:18:06 +00:00
|
|
|
this.$.passwordInfo.show();
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
2015-03-27 19:10:49 +00:00
|
|
|
|
2021-03-31 10:18:25 +00:00
|
|
|
,onAddressesClick: function() {
|
|
|
|
this.hash.set({form: 'account/address-list'});
|
2015-03-27 19:10:49 +00:00
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
});
|
|
|
|
|