2015-01-23 13:09:30 +00:00
|
|
|
|
2016-09-26 09:28:47 +00:00
|
|
|
Hedera.Conf = new Class
|
2015-01-23 13:09:30 +00:00
|
|
|
({
|
2016-09-26 09:28:47 +00:00
|
|
|
Extends: Hedera.Form
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
,activate: function ()
|
|
|
|
{
|
2015-03-27 19:10:49 +00:00
|
|
|
this.$('user-model').setInfo ('c', 'customer_view', 'hedera');
|
|
|
|
this.$('addresses').setInfo ('a', 'address_view', 'hedera');
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
2016-10-11 14:45:10 +00:00
|
|
|
|
|
|
|
,onPassChangeClick: function ()
|
|
|
|
{
|
|
|
|
this.$('old-password').value = '';
|
|
|
|
this.$('new-password').value = '';
|
|
|
|
this.$('repeat-password').value = '';
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2016-10-14 10:58:35 +00:00
|
|
|
var recoverPass = this.$('user-form').get ('recoverPass');
|
|
|
|
this.$('old-password').style.display = recoverPass ? 'none' : 'block';
|
2016-10-11 14:45:10 +00:00
|
|
|
this.$('change-password').show ();
|
|
|
|
|
2016-10-14 10:58:35 +00:00
|
|
|
if (recoverPass)
|
2016-10-11 14:45:10 +00:00
|
|
|
this.$('new-password').focus ();
|
2016-10-14 10:58:35 +00:00
|
|
|
else
|
|
|
|
this.$('old-password').focus ();
|
2016-10-11 14:45:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,onPassModifyClick: function ()
|
2015-03-06 23:33:54 +00:00
|
|
|
{
|
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 == '')
|
|
|
|
throw new Error (_('Passwords empty'));
|
|
|
|
if (newPassword !== repeatedPassword)
|
|
|
|
throw new Error (_('Passwords doesn\'t match'));
|
|
|
|
|
|
|
|
var batch = new Sql.Batch ();
|
2016-10-14 10:58:35 +00:00
|
|
|
batch.addValues ({
|
|
|
|
'oldPassword': oldPassword,
|
|
|
|
'newPassword': newPassword
|
|
|
|
});
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2016-10-11 14:45:10 +00:00
|
|
|
var query = 'CALL account.userChangePassword (#oldPassword, #newPassword)';
|
|
|
|
this.conn.execQuery (query, this.onPasswordUpdate.bind (this), batch);
|
|
|
|
}
|
|
|
|
catch (e)
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2016-10-11 14:45:10 +00:00
|
|
|
Htk.Toast.showError (e.message);
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-06 23:33:54 +00:00
|
|
|
,onPasswordUpdate: function (resultSet)
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2016-10-11 14:45:10 +00:00
|
|
|
try {
|
|
|
|
resultSet.fetchResult ();
|
|
|
|
this.$('change-password').hide ();
|
|
|
|
Htk.Toast.showMessage (_('Password changed!'));
|
2016-10-14 10:58:35 +00:00
|
|
|
this.$('user-form').refresh ();
|
2016-10-11 14:45:10 +00:00
|
|
|
}
|
|
|
|
catch (e)
|
|
|
|
{
|
|
|
|
Htk.Toast.showError (_('Password doesn\'t meet the requirements'));
|
|
|
|
this.$('old-password').select ();
|
|
|
|
}
|
2015-03-06 23:33:54 +00:00
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2016-10-11 14:45:10 +00:00
|
|
|
,onPassInfoClick: function ()
|
2015-03-06 23:33:54 +00:00
|
|
|
{
|
2016-10-11 14:45:10 +00:00
|
|
|
this.$('password-info').show ();
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
2015-03-27 19:10:49 +00:00
|
|
|
|
2015-07-23 15:58:48 +00:00
|
|
|
,onAddressesClick: function ()
|
2015-03-27 19:10:49 +00:00
|
|
|
{
|
2015-07-23 15:58:48 +00:00
|
|
|
this.hash.set ({'form': 'account/address-list'});
|
2015-03-27 19:10:49 +00:00
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
});
|
|
|
|
|