summaryrefslogtreecommitdiff
path: root/postgresqleu/auth.py
diff options
context:
space:
mode:
authorMagnus Hagander2020-02-26 17:31:29 +0000
committerMagnus Hagander2020-02-26 17:31:29 +0000
commit8b3bc7d42b871ed2d396b49014501e63321efbc1 (patch)
tree0797022f0ddefa9308eed6da8d6fefebaa5a6e8e /postgresqleu/auth.py
parent1d28d52aab9735e366efe5d19923fa102df18ea0 (diff)
Sync up postgresql community auth plugin to latest-and-greatest
Diffstat (limited to 'postgresqleu/auth.py')
-rw-r--r--postgresqleu/auth.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/postgresqleu/auth.py b/postgresqleu/auth.py
index f90b1b13..4ae553b2 100644
--- a/postgresqleu/auth.py
+++ b/postgresqleu/auth.py
@@ -133,13 +133,25 @@ def auth_receive(request):
a different username than %s.
This is almost certainly caused by some legacy data in our database.
-Please send an email to webmaster@postgresql.eu, indicating the username
+Please send an email to webmaster@postgresql.org, indicating the username
and email address from above, and we'll manually merge the two accounts
for you.
We apologize for the inconvenience.
""" % (data['e'][0], data['u'][0]), content_type='text/plain')
+ if getattr(settings, 'PGAUTH_CREATEUSER_CALLBACK', None):
+ res = getattr(settings, 'PGAUTH_CREATEUSER_CALLBACK')(
+ data['u'][0],
+ data['e'][0],
+ ['f'][0],
+ data['l'][0],
+ )
+ # If anything is returned, we'll return that as our result.
+ # If None is returned, it means go ahead and create the user.
+ if res:
+ return res
+
user = User(username=data['u'][0],
first_name=data['f'][0],
last_name=data['l'][0],
@@ -191,8 +203,9 @@ def user_search(searchterm=None, userid=None):
else:
q = {'s': searchterm}
- r = requests.get('{0}search/'.format(settings.PGAUTH_REDIRECT),
- params=q,
+ r = requests.get(
+ '{0}search/'.format(settings.PGAUTH_REDIRECT),
+ params=q,
)
if r.status_code != 200:
return []