Skip to content
Open
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
17 changes: 13 additions & 4 deletions templates/v3/accounts/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
redirect_field_value (string, optional, default unset) — URL to redirect to after login; hidden input omitted when unset
contributor_account_redirect_message (string, optional, default unset) — message for pre-created author/maintainer accounts; alert omitted when unset
{% endcomment %}
{% load static %}
{% load static socialaccount %}

{% block auth_content %}
<div class="auth-page__header">
Expand All @@ -28,7 +28,7 @@ <h1 class="auth-page__title">Login to your account</h1>

<form class="auth-page__card"
method="post"
action=""
action="{% url 'account_login' %}"
novalidate
{# djlint:off #}
x-data="{ hasErrors: false }"
Expand Down Expand Up @@ -70,8 +70,17 @@ <h1 class="auth-page__title">Login to your account</h1>
<p class="auth-page__divider">OR</p>

<div class="auth-page__social-card">
{% include "v3/includes/_button.html" with label="Continue with GitHub" url="#" icon_name="github" style="secondary" %}
{% include "v3/includes/_button.html" with label="Continue with Google" url="#" icon_name="google-colored" style="secondary" %}
{% get_providers as socialaccount_providers %}
{% if socialaccount_providers %}
{% for provider in socialaccount_providers %}
{% provider_login_url provider process="login" scope=scope auth_params=auth_params as href %}
{% if provider.name == "GitHub" %}
{% include "v3/includes/_button.html" with label="Continue with "|add:provider.name url=href icon_name="github" style="secondary" %}
{% elif provider.name == "Google" %}
{% include "v3/includes/_button.html" with label="Continue with "|add:provider.name url=href icon_name="google-colored" style="secondary" %}
{% endif %}
{% endfor %}
{% endif %}
{% include "v3/includes/_button.html" with label="Don't have an account? Sign up →" url=signup_url style="primary" %}
</div>
{% endblock auth_content %}
4 changes: 3 additions & 1 deletion users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,9 @@ def form_invalid(self, form):
return res if res else super().form_invalid(form)


class CustomLoginView(LoginView):
class CustomLoginView(V3AuthContextMixin, LoginView):
v3_template_name = "v3/accounts/login.html"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the V3Mixing dispatches, it sets _v3_active = False for POST requests, so it falls through the legacy login page. That means, if an error occurs during login, we're redirected to the legacy page.
To reproduce:

  • Go to login page;
  • Insert an email;
  • Insert a wrong password and submit;
Image

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fixed with changes made in the base branch, to better handle V3 integrations

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["contributor_account_redirect_message"] = self.request.session.pop(
Expand Down
Loading