improve login so that it can redirect to app authorization properly
This commit is contained in:
parent
5d9afbd06e
commit
b7833126e3
10 changed files with 18 additions and 13 deletions
|
@ -111,7 +111,7 @@
|
|||
{% else %}
|
||||
<section>
|
||||
<p class="empty">
|
||||
<span><a href="{% url 'users:login' %}?next={{ request.path }}">
|
||||
<span><a href="{% url 'users:login' %}?next={{ request.path | urlencode }}">
|
||||
{% trans 'Login or register to review or add this item to your collection.' %}
|
||||
</a></span>
|
||||
</p>
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
{% blocktrans %}You may have visited an incorrect URL, or the content you are looking for has been deleted by the author.{% endblocktrans %}
|
||||
<br>
|
||||
{% blocktrans %}If you believe this is our mistake, please contact us through the link at the bottom of the page.{% endblocktrans %}
|
||||
<a href="{% url 'common:home' %}" class="button">{trans "Go to Home"}</a>
|
||||
</article>
|
||||
</main>
|
||||
{% include "_footer.html" %}
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
{% endif %}
|
||||
{% else %}
|
||||
<li>
|
||||
<a href="{% url 'users:login' %}?next={{ request.path }}">{% trans 'Sign up or Login' %}</a>
|
||||
<a href="{% url 'users:login' %}?next={{ request.path | urlencode }}">{% trans 'Sign up or Login' %}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
|
|
@ -89,6 +89,7 @@ def error_403(request, exception=None):
|
|||
|
||||
|
||||
def error_404(request, exception=None):
|
||||
request.session.pop("next_url", None)
|
||||
return render(request, "404.html", status=404, context={"exception": exception})
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import datetime
|
||||
from urllib.parse import quote_plus
|
||||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.shortcuts import render
|
||||
|
@ -25,7 +26,10 @@ def profile(request: AuthedHttpRequest, user_name):
|
|||
return render(
|
||||
request,
|
||||
"users/home_anonymous.html",
|
||||
{"identity": target, "redir": f"/account/login?next={target.url}"},
|
||||
{
|
||||
"identity": target,
|
||||
"redir": f"/account/login?next={quote_plus(target.url)}",
|
||||
},
|
||||
)
|
||||
|
||||
if (target.local and user_name != target.handle) or (
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<article>
|
||||
<details>
|
||||
<summary>{% trans "Display name, avatar and other information" %}</summary>
|
||||
<form action="{% url 'users:profile' %}?next={{ request.path }}"
|
||||
<form action="{% url 'users:profile' %}"
|
||||
method="post"
|
||||
{% if request.user.mastodon and not request.user.preference.mastodon_skip_userinfo %}onsubmit="return confirm('{% trans "Updating profile information here will turn off automatic sync of display name, bio and avatar from your Mastodon instance. Sure to continue?" %}')"{% endif %}
|
||||
enctype="multipart/form-data">
|
||||
|
@ -42,8 +42,7 @@
|
|||
<article>
|
||||
<details>
|
||||
<summary>{% trans 'Email' %}</summary>
|
||||
<form action="{% url 'users:register' %}?next={{ request.path }}"
|
||||
method="post">
|
||||
<form action="{% url 'users:register' %}" method="post">
|
||||
<input value="{{ request.user.username }}" type="hidden" name="username" />
|
||||
<fieldset>
|
||||
<label>
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
</header>
|
||||
<div>
|
||||
{% if request.user.is_authenticated %}
|
||||
<a href="{{ request.session.next_url | default:'/' }}" class="button">{% trans 'back to your home page.' %}</a>
|
||||
<a href="{{ request.session.next_url | default:'/' }}" class="button">{% trans 'Continue' %}</a>
|
||||
{% elif allow_any_site %}
|
||||
<div role="group">
|
||||
{% if enable_email %}
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
<h4>{% trans 'Verify Your Email' %}</h4>
|
||||
{% if success %}
|
||||
<p>
|
||||
{{ request.user.email }} {% trans "verified successfully." %}
|
||||
{{ request.user.email }} {% trans "Verified successfully." %}
|
||||
<br>
|
||||
<a href="{% url 'common:home' %}">{% trans "back to your home page." %}</a>
|
||||
<a href="{{ request.session.next_url | default:'/' }}" class="button">{% trans 'Continue' %}</a>
|
||||
</p>
|
||||
{% else %}
|
||||
<p>
|
||||
{{ error }}
|
||||
<a href="{% url 'users:login' %}">{% trans "login again" %}</a>
|
||||
<a href="{% url 'users:login' %}">{% trans "Login again" %}</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
</article>
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
<h4>{% trans "Welcome" %}</h4>
|
||||
<p>
|
||||
{% blocktrans %}
|
||||
{{ site_name }} is flourishing because of collaborations and contributions from users like you. Please read our <a href="/pages/terms">term of service</a>, and feel free to <a href="{{ support_link }}">contact us</a> if you have any question or feedback.
|
||||
{{ site_name }} is flourishing because of collaborations and contributions from users like you. Please read our <a href="/pages/rules">rules</a>, and feel free to <a href="{{ support_link }}">contact us</a> if you have any question or feedback.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
<form action="{{ request.session.next_url | default:'/' }}" method="get">
|
||||
<input type="submit" value="{% trans 'Cut the sh*t and get me in!' %}">
|
||||
<input type="submit" value="{% trans 'Accept' %}">
|
||||
</form>
|
||||
</article>
|
||||
</div>
|
||||
|
|
|
@ -131,7 +131,7 @@ def register(request: AuthedHttpRequest):
|
|||
auth_login(request, new_user)
|
||||
return render(request, "users/welcome.html")
|
||||
else:
|
||||
return redirect(reverse("common:home"))
|
||||
return redirect(request.session.get("next_url", reverse("common:home")))
|
||||
|
||||
# use verified email if presents for new account creation
|
||||
if verified_account and verified_account.platform == Platform.EMAIL:
|
||||
|
|
Loading…
Add table
Reference in a new issue