summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander2025-06-02 14:45:42 +0000
committerMagnus Hagander2025-06-02 14:45:42 +0000
commit4e6be7b1cb30d291681fbf37c989123513ee0844 (patch)
tree3ba984571c3abe83124874cf67a49248b92218d7
parent3ecd0920291870304ce71e5b6800d310b84b3fc2 (diff)
Don't allow log-in at all for users with no permissions
-rw-r--r--pgmailmgr/mailmgr/models.py1
-rw-r--r--pgmailmgr/mailmgr/views.py4
-rw-r--r--pgmailmgr/settings.py7
-rw-r--r--pgmailmgr/urls.py1
4 files changed, 13 insertions, 0 deletions
diff --git a/pgmailmgr/mailmgr/models.py b/pgmailmgr/mailmgr/models.py
index 61c1cbd..fb33401 100644
--- a/pgmailmgr/mailmgr/models.py
+++ b/pgmailmgr/mailmgr/models.py
@@ -1,4 +1,5 @@
from django.db import models
+from django.http import HttpResponse
from django.contrib.auth.models import User
from django.db.models import signals
diff --git a/pgmailmgr/mailmgr/views.py b/pgmailmgr/mailmgr/views.py
index 85ef75d..e736f5a 100644
--- a/pgmailmgr/mailmgr/views.py
+++ b/pgmailmgr/mailmgr/views.py
@@ -16,6 +16,10 @@ def log(user, what):
l.save()
+def noaccess(request):
+ return HttpResponse("Access to this site is only for pre-approved users")
+
+
@login_required
def home(request):
admperm = request.user.is_superuser or \
diff --git a/pgmailmgr/settings.py b/pgmailmgr/settings.py
index d50055d..5c46d18 100644
--- a/pgmailmgr/settings.py
+++ b/pgmailmgr/settings.py
@@ -164,4 +164,11 @@ DEBUG = False
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_DOMAIN = "webmail.postgresql.org"
+
+def PGAUTH_CREATEUSER_CALLBACK(a, b, c, d):
+ from django.http import HttpResponseRedirect
+
+ return HttpResponseRedirect("/noaccess/")
+
+
from .settings_local import *
diff --git a/pgmailmgr/urls.py b/pgmailmgr/urls.py
index 882cf21..5aa0fd8 100644
--- a/pgmailmgr/urls.py
+++ b/pgmailmgr/urls.py
@@ -9,6 +9,7 @@ admin.autodiscover()
urlpatterns = [
re_path(r'^$', views.home),
+ re_path(r'^noaccess/$', views.noaccess),
re_path(r'^(\d+)/$', views.mailbox),
re_path(r'^adm/$', views.adm_home),
re_path(r'^adm/user/(\d+|add)/$', views.userform),