Skip to content

Commit 51fc1b0

Browse files
authored
fix: OPTIC-1472: Next parameter isn't being set on /user/login after failed auth (#6813)
Co-authored-by: mcanu <[email protected]>
1 parent ae02d97 commit 51fc1b0

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

label_studio/core/settings/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@
526526
PROJECT_TITLE_MIN_LEN = 3
527527
PROJECT_TITLE_MAX_LEN = 50
528528
LOGIN_REDIRECT_URL = '/'
529-
LOGIN_URL = '/'
529+
LOGIN_URL = '/user/login/'
530530
MIN_GROUND_TRUTH = 10
531531
DATA_UNDEFINED_NAME = '$undefined$'
532532
LICENSE = {}

label_studio/users/templates/users/new-ui/user_login.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% block user_content %}
44
<div class="form-wrapper">
55
<h2>Log in</h2>
6-
<form id="login-form" action="{% url 'user-login' %}{% if next %}?next={{ next }}{% endif %}" method="post">
6+
<form id="login-form" action="{% url 'user-login' %}?next={{ next }}" method="post">
77
{% csrf_token %}
88
<div class="input-wrapper">
99
<label>Email Address</label>
@@ -30,7 +30,7 @@ <h2>Log in</h2>
3030
{% if not settings.DISABLE_SIGNUP_WITHOUT_LINK %}
3131
<div class="text-wrapper">
3232
<p class="">Don't have an account?</p>
33-
<a href="{{ settings.HOSTNAME }}/user/signup">Sign up</a>
33+
<a href="{% url 'user-signup' %}{% querystring %}">Sign up</a>
3434
</div>
3535
{% endif %}
3636
{% endblock %}

label_studio/users/templates/users/new-ui/user_signup.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="form-wrapper">
66
<h2>Sign Up</h2>
77
<form id="signup-form"
8-
action="{% url 'user-signup' %}?{% if next %}&next={{ next }}{% endif %}{% if token %}&token={{ token }}{% endif %}"
8+
action="{% url 'user-signup' %}?next={{ next }}{% if token %}&token={{ token }}{% endif %}"
99
method="post"
1010
>
1111
{% csrf_token %}
@@ -69,7 +69,7 @@ <h2>Sign Up</h2>
6969
</div>
7070
<div class="text-wrapper">
7171
<p class="">Already have an account?</p>
72-
<a href="{{ settings.HOSTNAME }}/user/login">Log in</a>
72+
<a href="{% url 'user-login' %}{% querystring %}">Log in</a>
7373
</div>
7474
<script>
7575
document.querySelector("#how_find_us").addEventListener('change', function(e) {

label_studio/users/templates/users/user_login.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% extends 'users/user_base.html' %}
22

33
{% block user_content %}
4-
<form id="login-form" action="{% url 'user-login' %}{% if next %}?next={{ next }}{% endif %}" method="post">
4+
<form id="login-form" action="{% url 'user-login' %}?next={{ next }}" method="post">
55
{% csrf_token %}
66
<p><input type="text" class="lsf-input-ls" name="email" id="email" placeholder="Email" value="{{ form.data.email }}"></p>
77
<p><input type="password" class="lsf-input-ls" name="password" id="password" placeholder="Password"></p>

label_studio/users/templates/users/user_signup.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{% block user_content %}
55

66
<form id="signup-form"
7-
action="{% url 'user-signup' %}?{% if next %}&next={{ next }}{% endif %}{% if token %}&token={{ token }}{% endif %}"
7+
action="{% url 'user-signup' %}?next={{ next }}{% if token %}&token={{ token }}{% endif %}"
88
method="post"
99
>
1010
{% csrf_token %}

label_studio/users/views.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""This file and its contents are licensed under the Apache License 2.0. Please see the included NOTICE for copyright information and LICENSE for a copy of the license.
22
"""
33
import logging
4+
from urllib.parse import quote
45

56
from core.feature_flags import flag_set
67
from core.middleware import enforce_csrf_checks
@@ -73,7 +74,7 @@ def user_signup(request):
7374
{
7475
'user_form': user_form,
7576
'organization_form': organization_form,
76-
'next': next_page,
77+
'next': quote(next_page),
7778
'token': token,
7879
'found_us_options': forms.FOUND_US_OPTIONS,
7980
'elaborate': forms.FOUND_US_ELABORATE,
@@ -86,7 +87,7 @@ def user_signup(request):
8687
{
8788
'user_form': user_form,
8889
'organization_form': organization_form,
89-
'next': next_page,
90+
'next': quote(next_page),
9091
'token': token,
9192
},
9293
)
@@ -125,9 +126,9 @@ def user_login(request):
125126
return redirect(next_page)
126127

127128
if flag_set('fflag_feat_front_lsdv_e_297_increase_oss_to_enterprise_adoption_short'):
128-
return render(request, 'users/new-ui/user_login.html', {'form': form, 'next': next_page})
129+
return render(request, 'users/new-ui/user_login.html', {'form': form, 'next': quote(next_page)})
129130

130-
return render(request, 'users/user_login.html', {'form': form, 'next': next_page})
131+
return render(request, 'users/user_login.html', {'form': form, 'next': quote(next_page)})
131132

132133

133134
@login_required

0 commit comments

Comments
 (0)