96 lines
1.9 KiB
JavaScript
96 lines
1.9 KiB
JavaScript
|
|
Hedera.Conf = new Class
|
|
({
|
|
Extends: Hedera.Form
|
|
|
|
,activate: function ()
|
|
{
|
|
this.$.userModel.setInfo ('c', 'customer_view', 'hedera');
|
|
|
|
if (this.hash.$.changePass)
|
|
this.onPassChangeClick ();
|
|
}
|
|
|
|
,onChangePassOpen: function ()
|
|
{
|
|
this.hash.assign ({changePass: true});
|
|
}
|
|
|
|
,onChangePassClose: function ()
|
|
{
|
|
this.hash.assign ({changePass: undefined});
|
|
}
|
|
|
|
,onPassChangeClick: function ()
|
|
{
|
|
this.$.oldPassword.value = '';
|
|
this.$.newPassword.value = '';
|
|
this.$.repeatPassword.value = '';
|
|
|
|
var recoverPass = this.$.user.get ('recoverPass');
|
|
this.$.oldPassword.style.display = recoverPass ? 'none' : 'block';
|
|
this.$.changePassword.show ();
|
|
|
|
var focusInput;
|
|
|
|
if (recoverPass)
|
|
focusInput = this.$.newPassword;
|
|
else
|
|
focusInput = this.$.oldPassword;
|
|
|
|
focusInput.focus ();
|
|
focusInput.select ();
|
|
}
|
|
|
|
,onPassModifyClick: function ()
|
|
{
|
|
try {
|
|
var oldPassword = this.$.oldPassword.value;
|
|
var newPassword = this.$.newPassword.value;
|
|
var repeatedPassword = this.$.repeatPassword.value;
|
|
|
|
if (newPassword == '' && repeatedPassword == '')
|
|
throw new Error (_('Passwords empty'));
|
|
if (newPassword !== repeatedPassword)
|
|
throw new Error (_('Passwords doesn\'t match'));
|
|
|
|
var params = {
|
|
oldPassword: oldPassword,
|
|
newPassword: newPassword
|
|
};
|
|
this.conn.send ('core/change-password', params,
|
|
this._onPassChange.bind (this));
|
|
}
|
|
catch (e)
|
|
{
|
|
Htk.Toast.showError (e.message);
|
|
}
|
|
}
|
|
|
|
,_onPassChange: function (json, error)
|
|
{
|
|
if (json)
|
|
{
|
|
this.$.changePassword.hide ();
|
|
Htk.Toast.showMessage (_('Password changed!'));
|
|
this.$.user.refresh ();
|
|
}
|
|
else
|
|
{
|
|
Htk.Toast.showError (error.message);
|
|
this.$.oldPassword.select ();
|
|
}
|
|
}
|
|
|
|
,onPassInfoClick: function ()
|
|
{
|
|
this.$.passwordInfo.show ();
|
|
}
|
|
|
|
,onAddressesClick: function ()
|
|
{
|
|
this.hash.setAll ({form: 'account/address-list'});
|
|
}
|
|
});
|
|
|