Skip to content
Snippets Groups Projects
Commit 00683755 authored by Fynn Becker's avatar Fynn Becker :crab:
Browse files

Always fetch accounts by username

parent d04112f2
No related branches found
No related tags found
No related merge requests found
Pipeline #16383 failed
......@@ -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)
......
......@@ -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",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment