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
Branches master
Tags v2.2.0
No related merge requests found
Pipeline #16383 failed
...@@ -4,7 +4,6 @@ It should never be imported directly. ...@@ -4,7 +4,6 @@ It should never be imported directly.
Instead import the .utils module which will re-export this module's items if Instead import the .utils module which will re-export this module's items if
django is available. django is available.
""" """
from django.conf import settings
from django.utils import dateparse, timezone as django_tz from django.utils import dateparse, timezone as django_tz
from postgrestutils.typing import DatetimeOrStr from postgrestutils.typing import DatetimeOrStr
...@@ -17,13 +16,10 @@ def autofetch(sender, **kwargs): ...@@ -17,13 +16,10 @@ def autofetch(sender, **kwargs):
"""Fetch user account on login based on the AUTOFETCH configuration""" """Fetch user account on login based on the AUTOFETCH configuration"""
import postgrestutils import postgrestutils
payload = {"select": app_settings.AUTOFETCH} payload = {
"select": app_settings.AUTOFETCH,
if settings.DEBUG: "username": "eq.{}".format(kwargs["user"].get_username())
# 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)
with postgrestutils.Session() as s: with postgrestutils.Session() as s:
account = s.get("account", params=payload) account = s.get("account", params=payload)
......
...@@ -10,7 +10,7 @@ os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) ...@@ -10,7 +10,7 @@ os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
setup( setup(
name="postgrestutils", name="postgrestutils",
version="2.1.0", version="2.2.0",
packages=find_packages(), packages=find_packages(),
include_package_data=True, include_package_data=True,
license="BSD", license="BSD",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment