public inbox for pgsql-www@postgresql.org  
help / color / mirror / Atom feed
From: Célestin Matte <celestin.matte@cmatte.me>
To: pgsql-www@postgresql.org
Subject: [PATCH] pgweb: auth.py: make it possible to customize email address in error message
Date: Tue, 19 Dec 2023 17:51:47 +0100
Message-ID: <79ee1e4d-ef04-414e-a5e0-1732590ff763@cmatte.me> (raw)

auth.py contains an error message with an hardcoded @postgresql.org email address.
This patch makes it possible to change it using a variable in the settings.
I used ADMINS because it already exists in pgweb with the correct value (and pgarchives), but that can be discussed as it doesn't exist in pglister.

-- 
Célestin Matte

Attachments:

  [text/x-patch] 0001-auth.py-make-it-possible-to-customize-email-address-.patch (1.7K, 2-0001-auth.py-make-it-possible-to-customize-email-address-.patch)
  download | inline diff:
From 0943570f333379bc1235d60f169dc6e9721ec0e3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9lestin=20Matte?= <dev@cmatte.me>
Date: Tue, 19 Dec 2023 17:47:41 +0100
Subject: [PATCH] auth.py: make it possible to customize email address in error
 message

---
 tools/communityauth/sample/django/auth.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/communityauth/sample/django/auth.py b/tools/communityauth/sample/django/auth.py
index b6f60674..3cb32387 100644
--- a/tools/communityauth/sample/django/auth.py
+++ b/tools/communityauth/sample/django/auth.py
@@ -153,16 +153,20 @@ 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')(
-- 
2.43.0



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-www@postgresql.org
  Cc: celestin.matte@cmatte.me
  Subject: Re: [PATCH] pgweb: auth.py: make it possible to customize email address in error message
  In-Reply-To: <79ee1e4d-ef04-414e-a5e0-1732590ff763@cmatte.me>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox