From d5c84ded0e39a482fcf5ab51b467a336b61763b4 Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Thu, 12 Sep 2024 11:05:29 +0200 Subject: [PATCH] Add system check for SINGLE_USER mode --- users/__init__.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/users/__init__.py b/users/__init__.py index e69de29..7a841d5 100644 --- a/users/__init__.py +++ b/users/__init__.py @@ -0,0 +1,16 @@ +from django.core.checks import Warning, register + + +@register("users") +def check_single_user_implies_disabled_registration(app_configs, **kwargs): + from bugsink.app_settings import get_settings + errors = [] + if get_settings().SINGLE_USER and get_settings().USER_REGISTRATION != "CB_NOBODY": + errors.append( + Warning( + "You're in SINGLE_USER mode, but USER_REGISTRATION is not set to 'CB_NOBODY'. This means that users " + "can still register, which is probably not what you want.", + id="users.W001", + ) + ) + return errors