Skip to content

Commit 4c824fe

Browse files
committed
In pgauth plugin, get email address in message from settings
When generating an error message with an email address in it, get that email address from the settings instead of being hardcoded. This is not that important on the postgresql.org properties, but we have some downstream uses of individual pieces that can benefit from it. Author: Célestin Matte <celestin.matte@cmatte.me>
1 parent ecd0581 commit 4c824fe

File tree

1 file changed

+7
-2
lines changed
  • tools/communityauth/sample/django

1 file changed

+7
-2
lines changed

tools/communityauth/sample/django/auth.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,21 @@ def auth_receive(request):
164164
# somehow fix that live, give a proper error message and
165165
# have somebody look at it manually.
166166
if User.objects.filter(email=data['e'][0]).exists():
167+
if hasattr(settings, 'ADMINS') and len(settings.ADMINS) > 0:
168+
contact = settings.ADMINS[0][1]
169+
else:
170+
contact = "webmaster@postgresql.org"
171+
167172
return HttpResponse("""A user with email %s already exists, but with
168173
a different username than %s.
169174
170175
This is almost certainly caused by some legacy data in our database.
171-
Please send an email to webmaster@postgresql.org, indicating the username
176+
Please send an email to %s, indicating the username
172177
and email address from above, and we'll manually merge the two accounts
173178
for you.
174179
175180
We apologize for the inconvenience.
176-
""" % (data['e'][0], data['u'][0]), content_type='text/plain')
181+
""" % (data['e'][0], data['u'][0], contact), content_type='text/plain')
177182

178183
if getattr(settings, 'PGAUTH_CREATEUSER_CALLBACK', None):
179184
res = getattr(settings, 'PGAUTH_CREATEUSER_CALLBACK')(

0 commit comments

Comments
 (0)