[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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user