From 4f1ebedc44dcc344d14af4a39951552f3c070769 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Fri, 1 Sep 2023 20:40:47 +0200 Subject: [PATCH] [FIX] Reference before assignment `ownership` doesn't exist at this point. To get the main character, `user` is used here. ``` Traceback (most recent call last): File "/home/allianceserver/venv/auth/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner response = get_response(request) File "/home/allianceserver/venv/auth/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/allianceserver/venv/auth/lib/python3.10/site-packages/esi/decorators.py", line 116, in _wrapped_view return view_func(request, token, *args, **kwargs) File "/home/allianceserver/venv/auth/lib/python3.10/site-packages/allianceauth/authentication/views.py", line 156, in sso_login user = authenticate(token=token) File "/home/allianceserver/venv/auth/lib/python3.10/site-packages/django/views/decorators/debug.py", line 42, in sensitive_variables_wrapper return func(*func_args, **func_kwargs) File "/home/allianceserver/venv/auth/lib/python3.10/site-packages/django/contrib/auth/__init__.py", line 77, in authenticate user = backend.authenticate(request, **credentials) File "/home/allianceserver/venv/auth/lib/python3.10/site-packages/allianceauth/authentication/backends.py", line 68, in authenticate if ownership.user.profile.main_character.character_id != token.character_id: UnboundLocalError: local variable 'ownership' referenced before assignment ``` --- allianceauth/authentication/backends.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/allianceauth/authentication/backends.py b/allianceauth/authentication/backends.py index 94ac066b..f7b2038f 100644 --- a/allianceauth/authentication/backends.py +++ b/allianceauth/authentication/backends.py @@ -65,7 +65,7 @@ class StateBackend(ModelBackend): # we've seen this character owner before. Re-attach to their old user account user = records[0].user if user.profile.main_character: - if ownership.user.profile.main_character.character_id != token.character_id: + if user.profile.main_character.character_id != token.character_id: ## this is an alt, enforce main only due to trust issues in SSO. if request: messages.error("Unable to authenticate with this Character, Please log in with the main character associated with this account. Then add this character from the dashboard.")