Skip to content

fix: OPTIC-1472: Next parameter isn't being set on /user/login after failed auth #6813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion label_studio/core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@
PROJECT_TITLE_MIN_LEN = 3
PROJECT_TITLE_MAX_LEN = 50
LOGIN_REDIRECT_URL = '/'
LOGIN_URL = '/'
LOGIN_URL = '/user/login/'
MIN_GROUND_TRUTH = 10
DATA_UNDEFINED_NAME = '$undefined$'
LICENSE = {}
Expand Down
4 changes: 2 additions & 2 deletions label_studio/users/templates/users/new-ui/user_login.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block user_content %}
<div class="form-wrapper">
<h2>Log in</h2>
<form id="login-form" action="{% url 'user-login' %}{% if next %}?next={{ next }}{% endif %}" method="post">
<form id="login-form" action="{% url 'user-login' %}?next={{ next }}" method="post">
{% csrf_token %}
<div class="input-wrapper">
<label>Email Address</label>
Expand All @@ -30,7 +30,7 @@ <h2>Log in</h2>
{% if not settings.DISABLE_SIGNUP_WITHOUT_LINK %}
<div class="text-wrapper">
<p class="">Don't have an account?</p>
<a href="{{ settings.HOSTNAME }}/user/signup">Sign up</a>
<a href="{% url 'user-signup' %}{% querystring %}">Sign up</a>
</div>
{% endif %}
{% endblock %}
4 changes: 2 additions & 2 deletions label_studio/users/templates/users/new-ui/user_signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="form-wrapper">
<h2>Sign Up</h2>
<form id="signup-form"
action="{% url 'user-signup' %}?{% if next %}&next={{ next }}{% endif %}{% if token %}&token={{ token }}{% endif %}"
action="{% url 'user-signup' %}?next={{ next }}{% if token %}&token={{ token }}{% endif %}"
method="post"
>
{% csrf_token %}
Expand Down Expand Up @@ -69,7 +69,7 @@ <h2>Sign Up</h2>
</div>
<div class="text-wrapper">
<p class="">Already have an account?</p>
<a href="{{ settings.HOSTNAME }}/user/login">Log in</a>
<a href="{% url 'user-login' %}{% querystring %}">Log in</a>
</div>
<script>
document.querySelector("#how_find_us").addEventListener('change', function(e) {
Expand Down
2 changes: 1 addition & 1 deletion label_studio/users/templates/users/user_login.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends 'users/user_base.html' %}

{% block user_content %}
<form id="login-form" action="{% url 'user-login' %}{% if next %}?next={{ next }}{% endif %}" method="post">
<form id="login-form" action="{% url 'user-login' %}?next={{ next }}" method="post">
{% csrf_token %}
<p><input type="text" class="lsf-input-ls" name="email" id="email" placeholder="Email" value="{{ form.data.email }}"></p>
<p><input type="password" class="lsf-input-ls" name="password" id="password" placeholder="Password"></p>
Expand Down
2 changes: 1 addition & 1 deletion label_studio/users/templates/users/user_signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% block user_content %}

<form id="signup-form"
action="{% url 'user-signup' %}?{% if next %}&next={{ next }}{% endif %}{% if token %}&token={{ token }}{% endif %}"
action="{% url 'user-signup' %}?next={{ next }}{% if token %}&token={{ token }}{% endif %}"
method="post"
>
{% csrf_token %}
Expand Down
9 changes: 5 additions & 4 deletions label_studio/users/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""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.
"""
import logging
from urllib.parse import quote

from core.feature_flags import flag_set
from core.middleware import enforce_csrf_checks
Expand Down Expand Up @@ -73,7 +74,7 @@
{
'user_form': user_form,
'organization_form': organization_form,
'next': next_page,
'next': quote(next_page),
'token': token,
'found_us_options': forms.FOUND_US_OPTIONS,
'elaborate': forms.FOUND_US_ELABORATE,
Expand All @@ -86,7 +87,7 @@
{
'user_form': user_form,
'organization_form': organization_form,
'next': next_page,
'next': quote(next_page),
'token': token,
},
)
Expand Down Expand Up @@ -125,9 +126,9 @@
return redirect(next_page)

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

return render(request, 'users/user_login.html', {'form': form, 'next': next_page})
return render(request, 'users/user_login.html', {'form': form, 'next': quote(next_page)})

Check warning on line 131 in label_studio/users/views.py

View check run for this annotation

Codecov / codecov/patch

label_studio/users/views.py#L131

Added line #L131 was not covered by tests


@login_required
Expand Down
Loading