diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 49ace1f32ed..c2027984c42 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -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):