From: Magnus Hagander Date: Mon, 1 Dec 2025 20:16:52 +0000 (+0100) Subject: In pgauth plugin, get email address in message from settings X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=4c824febef6e2de88481618dac33ea32d5d02ef5;p=pgweb.git 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 --- diff --git a/tools/communityauth/sample/django/auth.py b/tools/communityauth/sample/django/auth.py index 06cc609c..45159636 100644 --- a/tools/communityauth/sample/django/auth.py +++ b/tools/communityauth/sample/django/auth.py @@ -164,16 +164,21 @@ def auth_receive(request): # somehow fix that live, give a proper error message and # have somebody look at it manually. if User.objects.filter(email=data['e'][0]).exists(): + if hasattr(settings, 'ADMINS') and len(settings.ADMINS) > 0: + contact = settings.ADMINS[0][1] + else: + contact = "webmaster@postgresql.org" + return HttpResponse("""A user with email %s already exists, but with a different username than %s. This is almost certainly caused by some legacy data in our database. -Please send an email to webmaster@postgresql.org, indicating the username +Please send an email to %s, 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') +""" % (data['e'][0], data['u'][0], contact), content_type='text/plain') if getattr(settings, 'PGAUTH_CREATEUSER_CALLBACK', None): res = getattr(settings, 'PGAUTH_CREATEUSER_CALLBACK')(