From 001ddf2cee639f67e1097f3012209f9fc9de6340 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Mon, 20 Jan 2025 21:58:06 +0100 Subject: [PATCH] adjust urls --- src/backend/InvenTree/InvenTree/settings.py | 28 +++++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/backend/InvenTree/InvenTree/settings.py b/src/backend/InvenTree/InvenTree/settings.py index 65344dd0f2..b10d3bdff1 100644 --- a/src/backend/InvenTree/InvenTree/settings.py +++ b/src/backend/InvenTree/InvenTree/settings.py @@ -1302,16 +1302,28 @@ SOCIALACCOUNT_ADAPTER = 'InvenTree.auth_overrides.CustomSocialAccountAdapter' ACCOUNT_ADAPTER = 'InvenTree.auth_overrides.CustomAccountAdapter' ACCOUNT_LOGOUT_ON_PASSWORD_CHANGE = True -# TDOO: Implement dynamic lookup for those + +# region to_be_moved +def get_frontend_url(pui_path: str): + """Generate frontend url. + + #TODO This function should be moved to the adapter once https://codeberg.org/allauth/django-allauth/issues/4226 is resolved. + """ + host: str = 'http://localhost:8000' + if not host.endswith('/'): + host += '/' + return f'{host}{FRONTEND_URL_BASE}/{pui_path}' + + HEADLESS_FRONTEND_URLS = { - 'account_confirm_email': 'http://localhost:8000/verify-email/{key}', # noqa: RUF027 - 'account_reset_password': 'http://localhost:8000/password-reset', - 'account_reset_password_from_key': 'http://localhost:8000/' - + FRONTEND_URL_BASE - + '/set-password?key={key}', # noqa: RUF027 - 'account_signup': 'http://localhost:8000/signup', - 'socialaccount_login_error': 'http://localhost:8000/social-login-error', + 'account_confirm_email': get_frontend_url('verify-email/{key}'), # noqa: RUF027 + 'account_reset_password': get_frontend_url('reset-password'), + 'account_reset_password_from_key': get_frontend_url('set-password?key={key}'), # noqa: RUF027 + 'account_signup': get_frontend_url('register'), + 'socialaccount_login_error': get_frontend_url('social-login-error'), } +# endregion to_be_moved + HEADLESS_ONLY = True HEADLESS_TOKEN_STRATEGY = 'InvenTree.auth_overrides.DRFTokenStrategy' MFA_ENABLED = get_boolean_setting(