From 8b270902c1444a1faa9efc0866b6c84a510578f2 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Thu, 14 Sep 2023 19:51:00 +0200 Subject: fix password changing form --- fietsboek/views/user_data.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fietsboek/views/user_data.py b/fietsboek/views/user_data.py index a7680e4..45c499c 100644 --- a/fietsboek/views/user_data.py +++ b/fietsboek/views/user_data.py @@ -48,16 +48,19 @@ def do_change_profile(request): :rtype: pyramid.response.Response """ password = request.params["password"] + # Save the identity as request.identity will be None after changing the + # password. + identity = request.identity if password: try: util.check_password_constraints(password, request.params["repeat-password"]) except ValueError as exc: request.session.flash(request.localizer.translate(exc.args[0])) return HTTPFound(request.route_url("user-data")) - request.identity.set_password(request.params["password"]) + identity.set_password(request.params["password"]) name = request.params["name"] - if request.identity.name != name: - request.identity.name = name + if identity.name != name: + identity.name = name request.session.flash(request.localizer.translate(_("flash.personal_data_updated"))) return HTTPFound(request.route_url("user-data")) -- cgit v1.2.3