0
1
Fork 0
hedera-web-mindshore/forms/account/conf/conf.js

82 lines
2.1 KiB
JavaScript
Raw Normal View History

2021-03-31 10:18:25 +00:00
Hedera.Conf = new Class({
2016-09-26 09:28:47 +00:00
Extends: Hedera.Form
2021-03-31 10:18:25 +00:00
,activate: function() {
this.$('user-model').setInfo('c', 'myClient', 'hedera');
console.log(this.hash.get('verificationToken'));
if (this.hash.get('verificationToken'))
this.onPassChangeClick();
}
2016-10-11 14:45:10 +00:00
2021-03-31 10:18:25 +00:00
,onPassChangeClick: function() {
2016-10-11 14:45:10 +00:00
this.$('old-password').value = '';
this.$('new-password').value = '';
this.$('repeat-password').value = '';
2021-03-31 10:18:25 +00:00
var verificationToken = this.hash.get('verificationToken');
this.$('old-password').style.display = verificationToken ? 'none' : 'block';
this.$('change-password').show();
2016-10-11 14:45:10 +00:00
2021-03-31 10:18:25 +00:00
if (verificationToken)
this.$('new-password').focus();
2016-10-14 10:58:35 +00:00
else
2021-03-31 10:18:25 +00:00
this.$('old-password').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 {
var oldPassword = this.$('old-password').value;
var newPassword = this.$('new-password').value;
var repeatedPassword = this.$('repeat-password').value;
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 {
params.oldPassword = oldPassword;
this.conn.send('core/change-password', params,
this._onPassChange.bind(this));
}
} catch (e) {
Htk.Toast.showError(e.message);
}
}
2021-03-31 10:18:25 +00:00
,_onPassChange: function(json, error) {
if (json) {
this.$('change-password').hide();
this.hash.unset('verificationToken');
Htk.Toast.showMessage(_('Password changed!'));
this.$('user-form').refresh();
} else {
Htk.Toast.showError(error.message);
if (this.hash.get('verificationToken'))
this.$('new-password').select();
else
this.$('old-password').select();
2016-10-11 14:45:10 +00:00
}
2015-03-06 23:33:54 +00:00
}
2021-03-31 10:18:25 +00:00
,onPassInfoClick: function() {
this.$('password-info').show();
}
2021-03-31 10:18:25 +00:00
,onAddressesClick: function() {
this.hash.set({form: 'account/address-list'});
}
});