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

59 lines
1.3 KiB
JavaScript

Hedera.Conf = new Class
({
Extends: Hedera.Form
,activate: function ()
{
this.$('user-model').setInfo ('u', 'user_view', 'hedera');
this.$('user-model').setInfo ('c', 'customer_view', 'hedera');
this.$('addresses').setInfo ('a', 'address_view', 'hedera');
}
,onPasswordChange: function ()
{
var newPassword = this.$('new-password').value;
var repeatedPassword = this.$('repeat-password').value;
if (newPassword != '' && repeatedPassword != '')
{
if (newPassword === repeatedPassword)
{
var batch = new Sql.Batch ();
batch.addValue ('password', newPassword);
var query = 'UPDATE user_view SET password = SHA2(#password, 256) '
+'WHERE id = account.user_get_id () LIMIT 1';
this.conn.execQuery (query, this.onPasswordUpdate.bind (this), batch);
}
else
Htk.Toast.showError (_('PasswordsDoesntMatch'));
}
}
,onPasswordUpdate: function (resultSet)
{
if (!resultSet.fetchResult ())
return;
this.relogin ();
Htk.Toast.showMessage (_('PasswordsChanged'));
}
,relogin: function ()
{
this.conn.open (
this.$('user-form').get ('name')
,this.$('new-password').value
,Vn.Cookie.check ('vn_pass')
);
}
,onAddressesClick: function ()
{
this.hash.set ({'form': 'account/address-list'});
}
});