From f70899b64a7a09a88a7937100d4db98214fbb6c2 Mon Sep 17 00:00:00 2001
From: Wes Appler <145372368+wes-otf@users.noreply.github.com>
Date: Tue, 9 Jul 2024 05:26:52 -0400
Subject: [PATCH] Fix login redirects (#4025)

Fixes #4022

Pretty sure the only issue with the
redirects was the `next` variable was never updated to the
`redirect_url` variable. Tested locally it works fine between the
passwordless/passworded logins but couldn't test with social login.
Everything I've seen online indicates this should work fine, though.
---
 hypha/templates/includes/org_login_button.html          | 2 +-
 hypha/templates/includes/password_login_button.html     | 2 +-
 hypha/templates/includes/passwordless_login_button.html | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hypha/templates/includes/org_login_button.html b/hypha/templates/includes/org_login_button.html
index f1e6ffb31..bf201e961 100644
--- a/hypha/templates/includes/org_login_button.html
+++ b/hypha/templates/includes/org_login_button.html
@@ -1,7 +1,7 @@
 {% load i18n heroicons %}
 <a
     class="button button--secondary button--login mb-4"
-    href="{% url "social:begin" "google-oauth2" %}{% if next %}?next={{ next }}{% endif %}"
+    href="{% url "social:begin" "google-oauth2" %}{% if redirect_url %}?next={{ redirect_url }}{% endif %}"
 >
     {% heroicon_mini "building-office" size=18 class="inline align-text-bottom me-1" aria_hidden=true %}
     {% blocktrans %}Log in with your {{ ORG_SHORT_NAME }} email{% endblocktrans %}
diff --git a/hypha/templates/includes/password_login_button.html b/hypha/templates/includes/password_login_button.html
index 8c6199ca9..d7dc1a705 100644
--- a/hypha/templates/includes/password_login_button.html
+++ b/hypha/templates/includes/password_login_button.html
@@ -1,7 +1,7 @@
 {% load i18n heroicons %}
 <a
     class="button button--secondary button--login"
-    href="{% url 'users:login' %}{% if next %}?next={{next}}{% endif %}"
+    href="{% url 'users:login' %}{% if redirect_url %}?next={{redirect_url}}{% endif %}"
 >
     {% heroicon_mini "key" size=18 class="inline align-text-bottom me-1" aria_hidden=true %}
     {% trans "Log in with password" %}
diff --git a/hypha/templates/includes/passwordless_login_button.html b/hypha/templates/includes/passwordless_login_button.html
index d3988e707..d5e761326 100644
--- a/hypha/templates/includes/passwordless_login_button.html
+++ b/hypha/templates/includes/passwordless_login_button.html
@@ -1,7 +1,7 @@
 {% load i18n heroicons %}
 <a
     class="button button--secondary button--login"
-    href="{% url 'users:passwordless_login_signup' %}{% if next %}?next={{next}}{% endif %}"
+    href="{% url 'users:passwordless_login_signup' %}{% if redirect_url %}?next={{redirect_url}}{% endif %}"
 >
     {% heroicon_mini "envelope" size=18 class="inline align-text-bottom me-1" aria_hidden=true %}
     {% trans "Log in without password" %}
-- 
GitLab