Skip to content

Commit

Permalink
Fix redirect after login prompt (#1786)
Browse files Browse the repository at this point in the history
Co-authored-by: Roelof Korporaal <[email protected]>
  • Loading branch information
dekkers and TwistMeister authored Sep 18, 2023
1 parent 0a17d92 commit fa952f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions rocky/rocky/middleware/auth_required.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from django.conf import settings
from django.contrib.auth.views import redirect_to_login
from django.shortcuts import redirect
from django.urls.base import reverse
from django.utils import translation


def AuthRequiredMiddleware(get_response):
def middleware(request):
login_path = reverse("login")
two_factor_setup_path = reverse("setup")
# URLs excluded from login and 2fa
excluded = [
"/",
login_path,
reverse("login"),
reverse("recover_email"),
reverse("password_reset"),
reverse("landing_page"),
Expand Down Expand Up @@ -40,7 +40,7 @@ def middleware(request):
# check if path starts with anything in excluded_prefix
or any([request.path.startswith(prefix) for prefix in excluded_prefix])
):
return redirect(login_path)
return redirect_to_login(request.get_full_path())

# When 2fa is enabled, check if user is verified, otherwise redirect to 2fa setup page
if (
Expand Down
2 changes: 1 addition & 1 deletion rocky/rocky/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
STATIC_ROOT = BASE_DIR / "static"
STATICFILES_DIRS = (BASE_DIR / "assets",)

LOGIN_URL = "two_factor:login"
LOGIN_URL = "login"
LOGIN_REDIRECT_URL = "crisis_room"

# Default primary key field type
Expand Down

0 comments on commit fa952f4

Please sign in to comment.