From f9839ea5cb9aac1a3b6d087a81b6d974793e260e Mon Sep 17 00:00:00 2001 From: Dzmitry Kushnarou Date: Wed, 15 May 2024 22:48:21 +0100 Subject: [PATCH] Fix bug: can't switch accounts after using old login mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem reason: account.id might not be available before account.save(), if the account is newly-created Changes: switches .save() call and accounts_dict update, to ensure that the .id is available in accounts_dict Note: this bugfix only fixes logins after this change. If you’ve logged in using the old code, your session data still won't have ID. You need to log out of all the accounts and then log in again. --- brutaldon/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brutaldon/views.py b/brutaldon/views.py index 971c520..6680e00 100644 --- a/brutaldon/views.py +++ b/brutaldon/views.py @@ -583,6 +583,7 @@ def old_login(request): account.username = request.session["active_username"] request.session["timezone"] = account.preferences.timezone + account.save() accounts_dict = request.session.get("accounts_dict") if not accounts_dict: accounts_dict = {} @@ -591,7 +592,6 @@ def old_login(request): "user": user, } request.session["accounts_dict"] = accounts_dict - account.save() return redirect(home) except IntegrityError: