}
@openerpweb.jsonrequest
def change_password (self,req,fields):
- old_password, new_password,confirm_password = operator.itemgetter('old_pwd', 'new_pwd','confirm_pwd')(
+ old_password, new_password,confirm_password = operator.itemgetter('old_pwd', 'new_password','confirm_pwd')(
dict(map(operator.itemgetter('name', 'value'), fields)))
+ if not (old_password.strip() and new_password.strip() and confirm_password.strip()):
+ return {'error':'All passwords have to be filled.','title': 'Change Password'}
+ if new_password != confirm_password:
+ return {'error': 'The new password and its confirmation must be identical.','title': 'Change Password'}
try:
if req.session.model('res.users').change_password(
old_password, new_password):
- req.session.password = new_password
- return dict(changed=True)
- raise redirect('/')
- except xmlrpclib.Fault, e:
+ req.session.password = new_password;
+ return dict(changed=True)
+ except:
return {'error': 'Original password incorrect, your password was not changed.', 'title': 'Change Password'}
@openerpweb.jsonrequest
}
self.notification.notify("Changed Password", "Password has been changed successfully");
});
- }
+ },
});
}
});
this.dialog.open();
this.dialog.$element.html(QWeb.render("Change_Pwd", self));
this.dialog.$element.find("form[name=change_password_form]").validate({
- messages: {
- old_password: "Please enter your previous password",
- new_password: "Please enter your new password",
- confirm_password: {
- required: "Please confirm your new password",
- equalTo: "The confirmation does not match the password"
- },
- },
submitHandler: function (form) {
+ console.log('form',form)
self.rpc("/base/session/change_password",{
- 'fields': $("form[name=change_password_form]").serializeArray()
+ 'fields': $(form).serializeArray()
}, function(result) {
if (result.error) {
self.display_error(result);
return;
- }
+ };
self.notification.notify("Changed Password", "Password has been changed successfully");
self.dialog.close();
});
</t>
<t t-name="Change_Pwd">
<form name="change_password_form" class="oe_forms" method="POST">
- <table align="center" class="db_option_table">
+ <table align="center">
<tr>
<td><label for="old_pwd">Old Password:</label></td>
- <td><input type="password" name="old_pwd" class="required"
+ <td><input type="password" name="old_pwd"
minlength="1" autofocus="autofocus"/></td>
</tr>
<tr>
- <td><label for="new_pwd">New Password:</label></td>
- <td><input type="password" name="new_pwd" class="required"
- minlength="1"/></td>
+ <td><label for="new_password">New Password:</label></td>
+ <td><input type="password" name="new_password"
+ minlength="1" autofocus="autofocus"/></td>
</tr>
- <tr>
+ <tr>
<td><label for="confirm_pwd">Confirm Password:</label></td>
- <td><input type="password" name="confirm_pwd" class="required"
- equalTo="input[name=new_pwd]" minlength="1"/></td>
+ <td><input type="password" name="confirm_pwd"
+ minlength="1"/></td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" value="Change Password"/></td>