Self hosted FLOSS fitness/workout, nutrition and weight tracker
Redirect the user directly in the middleware after logging in
Roland Geidere37471256aca
diff --git a/wger/core/middleware.py b/wger/core/middleware.pyindex fe529e759..6ed526956 100644--- a/wger/core/middleware.py+++ b/wger/core/middleware.py@@ -23,6 +23,7 @@ from django.contrib.auth import (login,logout,)+from django.shortcuts import redirectfrom django.urls import reversefrom django.utils.deprecation import MiddlewareMixin@@ -119,6 +120,9 @@ class AuthProxyHeaderMiddleware(MiddlewareMixin):f"AuthProxyMiddleware: User '{username}' authenticated via header from "f"trusted IP '{client_ip}'.")+ next_url = request.GET.get('next', reverse('core:dashboard'))+ if request.user.is_authenticated:+ return redirect(next_url)else:# Authentication failed (e.g., user couldn't be found/created by backend)logger.error(diff --git a/wger/core/tests/test_auth_proxy_middleware.py b/wger/core/tests/test_auth_proxy_middleware.pyindex b1fc8f772..52cf4ba75 100644--- a/wger/core/tests/test_auth_proxy_middleware.py+++ b/wger/core/tests/test_auth_proxy_middleware.py@@ -21,7 +21,6 @@ from django.test import ()from django.urls import reverse-User = get_user_model()TRUSTED_IP = '192.0.2.1'@@ -87,6 +86,7 @@ class AuthProxyMiddlewareTests(TestCase):AUTH_PROXY_CREATE_UNKNOWN_USER=True,AUTH_PROXY_USER_EMAIL_HEADER=PROXY_EMAIL_HEADER_KEY,AUTH_PROXY_USER_NAME_HEADER=PROXY_NAME_HEADER_KEY,+ WGER_SETTINGS={'ALLOW_GUEST_USERS': False},)def test_success_trusted_ip_new_user_created(self):self.assertFalse(User.objects.filter(username=NEW_USER_VALUE).exists())diff --git a/wger/settings.tpl b/wger/settings.tplindex d6ca2b50c..b57ffa858 100644--- a/wger/settings.tpl+++ b/wger/settings.tpl@@ -15,10 +15,6 @@ WGER_SETTINGS["ALLOW_GUEST_USERS"] = TrueWGER_SETTINGS["ALLOW_UPLOAD_VIDEOS"] = FalseWGER_SETTINGS["MIN_ACCOUNT_AGE_TO_TRUST"] = 21 # in daysWGER_SETTINGS["EXERCISE_CACHE_TTL"] = 3600 # in seconds-# can be used if there is authentication in front of wger, e.g.-# if authelia is used to authenticate the users. Users will be-# created with this username.-# WGER_SETTINGS["AUTH_PROXY_HEADER"] = "Remote-User"DATABASES = {{'default': {{