From 006837554d736c8e637c377e4daee54a7aafdbc3 Mon Sep 17 00:00:00 2001 From: Fynn <fynn.becker@hs-hannover.de> Date: Tue, 7 May 2024 11:52:38 +0200 Subject: [PATCH] Always fetch accounts by username --- postgrestutils/_django_utils.py | 12 ++++-------- setup.py | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/postgrestutils/_django_utils.py b/postgrestutils/_django_utils.py index bdea8c6..cbd3caa 100644 --- a/postgrestutils/_django_utils.py +++ b/postgrestutils/_django_utils.py @@ -4,7 +4,6 @@ It should never be imported directly. Instead import the .utils module which will re-export this module's items if django is available. """ -from django.conf import settings from django.utils import dateparse, timezone as django_tz from postgrestutils.typing import DatetimeOrStr @@ -17,13 +16,10 @@ def autofetch(sender, **kwargs): """Fetch user account on login based on the AUTOFETCH configuration""" import postgrestutils - payload = {"select": app_settings.AUTOFETCH} - - if settings.DEBUG: - # prod uuids != dev uuids, fall back on matching accounts by username - payload["username"] = "eq.{}".format(kwargs["user"].get_username()) - else: - payload["auth_provider_uid"] = "eq.{}".format(kwargs["user"].sso_mapping.uuid) + payload = { + "select": app_settings.AUTOFETCH, + "username": "eq.{}".format(kwargs["user"].get_username()) + } with postgrestutils.Session() as s: account = s.get("account", params=payload) diff --git a/setup.py b/setup.py index 8f24b87..02a27b6 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) setup( name="postgrestutils", - version="2.1.0", + version="2.2.0", packages=find_packages(), include_package_data=True, license="BSD", -- GitLab