mirror of
https://github.com/dkmstr/openuds.git
synced 2025-03-12 04:58:34 +03:00
Refactor authentication URLs to use enum values
This commit is contained in:
parent
b6a8892a63
commit
e9c6b117b8
@ -450,11 +450,12 @@ def web_logout(request: 'ExtendedHttpRequest', exit_url: typing.Optional[str] =
|
||||
Helper function to clear user related data from session. If this method is not used, the session we be cleaned anyway
|
||||
by django in regular basis.
|
||||
"""
|
||||
tag = request.session.get('tag', None)
|
||||
tag = request.session.pop('tag', None)
|
||||
if tag and config.GlobalConfig.REDIRECT_TO_TAG_ON_LOGOUT.as_bool(False):
|
||||
exit_page = reverse('page.login.tag', kwargs={'tag': tag})
|
||||
exit_page = reverse(types.auth.AuthenticationInternalUrl.LOGIN_TAG, kwargs={'tag': tag})
|
||||
else:
|
||||
exit_page = reverse('page.login')
|
||||
# remove, if exists, tag from session
|
||||
exit_page = reverse(types.auth.AuthenticationInternalUrl.LOGIN)
|
||||
exit_url = exit_url or exit_page
|
||||
try:
|
||||
if request.user:
|
||||
|
@ -52,12 +52,13 @@ class AuthenticationState(enum.IntEnum):
|
||||
REDIRECT = 2
|
||||
|
||||
|
||||
class AuthenticationInternalUrl(enum.Enum):
|
||||
class AuthenticationInternalUrl(enum.StrEnum):
|
||||
"""
|
||||
Enumeration for authentication success
|
||||
"""
|
||||
|
||||
LOGIN = 'page.login'
|
||||
LOGIN_TAG = 'page.login.tag'
|
||||
LOGOUT = 'page.logout'
|
||||
|
||||
def get_url(self) -> str:
|
||||
|
@ -101,12 +101,12 @@ urlpatterns = [
|
||||
re_path(
|
||||
r'^uds/page/login/(?P<tag>[a-zA-Z0-9-]+)$',
|
||||
uds.web.views.main.login,
|
||||
name='page.login.tag',
|
||||
name=types.auth.AuthenticationInternalUrl.LOGIN_TAG.value,
|
||||
),
|
||||
path(
|
||||
r'uds/page/logout',
|
||||
uds.web.views.main.logout,
|
||||
name='page.logout',
|
||||
name=types.auth.AuthenticationInternalUrl.LOGOUT.value,
|
||||
),
|
||||
# MFA authentication
|
||||
path(
|
||||
|
Loading…
x
Reference in New Issue
Block a user