Skip to content

Commit

Permalink
enables override of login/registration enabled/disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
smirolo committed Feb 19, 2025
1 parent 75454c1 commit fefe9b8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions djaoapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
DISABLED_USER_UPDATE = False

MULTITIER_SITE_MODEL = None
AUTHENTICATION_OVERRIDE = None
RULES_ENC_KEY_OVERRIDE = None
RULES_ENTRY_POINT_OVERRIDE = None
REQUESTS_TIMEOUT = 120
Expand Down
11 changes: 10 additions & 1 deletion djaoapp/thread_locals.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@

from .compat import reverse


LOGGER = logging.getLogger(__name__)

AUTH_ENABLED = 0
AUTH_LOGIN_ONLY = 1
AUTH_DISABLED = 2


def is_platformed_site():
#pylint:disable=protected-access
return not (get_current_broker()._state.db == DEFAULT_DB_ALIAS)
Expand Down Expand Up @@ -166,12 +170,17 @@ def get_active_theme():


def get_disabled_authentication(request, user):
if settings.AUTHENTICATION_OVERRIDE is not None:
return (settings.AUTHENTICATION_OVERRIDE == AUTH_DISABLED
and not _valid_manager(request, [get_current_broker()]))
app = get_current_app(request)
return (app.authentication == app.AUTH_DISABLED
and not _valid_manager(request, [get_current_broker()]))


def get_disabled_registration(request):#pylint:disable=unused-argument
if settings.AUTHENTICATION_OVERRIDE is not None:
return settings.AUTHENTICATION_OVERRIDE != AUTH_ENABLED
app = get_current_app(request)
return app.authentication != app.AUTH_ENABLED

Expand Down
1 change: 1 addition & 0 deletions etc/site.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ DB_NAME = "%(DB_FILENAME)s"

# Overrides the entry_point and encoding key to forward HTTP requests to
# (initially implemented for livedemo)
AUTHENTICATION_OVERRIDE = None
RULES_ENC_KEY_OVERRIDE = ""
RULES_ENTRY_POINT_OVERRIDE = ""
REQUESTS_TIMEOUT = 120
Expand Down

0 comments on commit fefe9b8

Please sign in to comment.