Hi Alex,
Thanks for adding changePassword to the register plugin. I'm now trying to create a form to use it. Below is what I have so far. At first glance it seems to work, but the service always returns 'success', even if the old password is incorrect, and it never has any effect, even if the old password is correct.
Am I doing something wrong?
Wouter
<script type="text/javascript"><!--
function submitPasswordForm(currentPass, newPass1, newPass2) {
if (newPass1 == "")
$('#password-messages').html('<span class="error-message">New password field is empty.</span>');
else if (newPass1 != newPass2)
$('#password-messages').html('<span class="error-message">Please enter the same password twice!</span>');
else
changePassword(currentPass, newPass1);
return false;
}
function changePassword(currentPass, newPass) {
Vosao.jsonrpc.registerFrontService.changePassword(function(r,e) {
if (Vosao.serviceFailed(e))
{
$('#password-messages').html('<span class="error-message">Password change failed.</span>');
document.location.href = '$page.friendlyURL';
}
else if (r.result == 'success')
{
$('#password-messages').html('<span class="success-message">Success.</span>');
document.location.href = '$page.friendlyURL';
} else {
$('#password-messages').html('<span class="error-message">' + r.message + '</span>');
}
}, $
user.id, currentPass, newPass);
}
//-->
</script>
<form method="get" action="$page.friendlyURL" onsubmit="return submitPasswordForm(currentPass.value, newPass1.value, newPass2.value);">
<div><label>Current password:</label> <input name="currentPass" type="password" value=""/></div>
<div><label>New password:</label> <input name="newPass1" type="password" value=""/></div>
<div><label>Retype password:</label> <input name="newPass2" type="password" value=""/></div>
<div id="password-messages"></div>
<div><input name="ChangePassword" type="submit" value="Change Password"/></div>
</form>