[FIX] web: user's change_password wizard

Auth can now report errors less trivial than "incorrect password", the
wizard should report them instead of just assuming the original
password was not correct.
This commit is contained in:
Xavier Morel
2018-10-02 20:54:00 +02:00
committed by Olivier Dony
parent a47f6093f8
commit 8fb358e563
+9 -3
View File
@@ -818,12 +818,18 @@ class Session(http.Controller):
return {'error':_('You cannot leave any password empty.'),'title': _('Change Password')}
if new_password != confirm_password:
return {'error': _('The new password and its confirmation must be identical.'),'title': _('Change Password')}
msg = _("Error, password not changed !")
try:
if request.env['res.users'].change_password(old_password, new_password):
return {'new_password':new_password}
except Exception:
return {'error': _('The old password you provided is incorrect, your password was not changed.'), 'title': _('Change Password')}
return {'error': _('Error, password not changed !'), 'title': _('Change Password')}
except UserError as e:
msg = e.name
except AccessDenied as e:
msg = e.args[0]
if msg == AccessDenied().args[0]:
msg = _('The old password you provided is incorrect, your password was not changed.')
return {'title': _('Change Password'), 'error': msg}
@http.route('/web/session/get_lang_list', type='json', auth="none")
def get_lang_list(self):