81 lines
1.8 KiB
JavaScript
81 lines
1.8 KiB
JavaScript
|
|
Hedera.Conf = new Class
|
|
({
|
|
Extends: Hedera.Form
|
|
|
|
,activate: function ()
|
|
{
|
|
this.$('user-model').setInfo ('c', 'customer_view', 'hedera');
|
|
this.$('addresses').setInfo ('a', 'address_view', 'hedera');
|
|
}
|
|
|
|
,onPassChangeClick: function ()
|
|
{
|
|
this.$('old-password').value = '';
|
|
this.$('new-password').value = '';
|
|
this.$('repeat-password').value = '';
|
|
|
|
var recoverPass = this.$('user-form').get ('recoverPass');
|
|
this.$('old-password').style.display = recoverPass ? 'none' : 'block';
|
|
this.$('change-password').show ();
|
|
|
|
if (recoverPass)
|
|
this.$('new-password').focus ();
|
|
else
|
|
this.$('old-password').focus ();
|
|
}
|
|
|
|
,onPassModifyClick: function ()
|
|
{
|
|
try {
|
|
var oldPassword = this.$('old-password').value;
|
|
var newPassword = this.$('new-password').value;
|
|
var repeatedPassword = this.$('repeat-password').value;
|
|
|
|
if (newPassword == '' && repeatedPassword == '')
|
|
throw new Error (_('Passwords empty'));
|
|
if (newPassword !== repeatedPassword)
|
|
throw new Error (_('Passwords doesn\'t match'));
|
|
|
|
var batch = new Sql.Batch ();
|
|
batch.addValues ({
|
|
'oldPassword': oldPassword,
|
|
'newPassword': newPassword
|
|
});
|
|
|
|
var query = 'CALL account.userChangePassword (#oldPassword, #newPassword)';
|
|
this.conn.execQuery (query, this.onPasswordUpdate.bind (this), batch);
|
|
}
|
|
catch (e)
|
|
{
|
|
Htk.Toast.showError (e.message);
|
|
}
|
|
}
|
|
|
|
,onPasswordUpdate: function (resultSet)
|
|
{
|
|
try {
|
|
resultSet.fetchResult ();
|
|
this.$('change-password').hide ();
|
|
Htk.Toast.showMessage (_('Password changed!'));
|
|
this.$('user-form').refresh ();
|
|
}
|
|
catch (e)
|
|
{
|
|
Htk.Toast.showError (_('Password doesn\'t meet the requirements'));
|
|
this.$('old-password').select ();
|
|
}
|
|
}
|
|
|
|
,onPassInfoClick: function ()
|
|
{
|
|
this.$('password-info').show ();
|
|
}
|
|
|
|
,onAddressesClick: function ()
|
|
{
|
|
this.hash.set ({'form': 'account/address-list'});
|
|
}
|
|
});
|
|
|