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 %}
|
{% else %}
|
||||||
<section>
|
<section>
|
||||||
<p class="empty">
|
<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.' %}
|
{% trans 'Login or register to review or add this item to your collection.' %}
|
||||||
</a></span>
|
</a></span>
|
||||||
</p>
|
</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 %}
|
{% blocktrans %}You may have visited an incorrect URL, or the content you are looking for has been deleted by the author.{% endblocktrans %}
|
||||||
<br>
|
<br>
|
||||||
{% blocktrans %}If you believe this is our mistake, please contact us through the link at the bottom of the page.{% endblocktrans %}
|
{% 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>
|
</article>
|
||||||
</main>
|
</main>
|
||||||
{% include "_footer.html" %}
|
{% include "_footer.html" %}
|
||||||
|
|
|
@ -115,7 +115,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<li>
|
<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>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -89,6 +89,7 @@ def error_403(request, exception=None):
|
||||||
|
|
||||||
|
|
||||||
def error_404(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})
|
return render(request, "404.html", status=404, context={"exception": exception})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import datetime
|
import datetime
|
||||||
|
from urllib.parse import quote_plus
|
||||||
|
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
@ -25,7 +26,10 @@ def profile(request: AuthedHttpRequest, user_name):
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
"users/home_anonymous.html",
|
"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 (
|
if (target.local and user_name != target.handle) or (
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<article>
|
<article>
|
||||||
<details>
|
<details>
|
||||||
<summary>{% trans "Display name, avatar and other information" %}</summary>
|
<summary>{% trans "Display name, avatar and other information" %}</summary>
|
||||||
<form action="{% url 'users:profile' %}?next={{ request.path }}"
|
<form action="{% url 'users:profile' %}"
|
||||||
method="post"
|
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 %}
|
{% 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">
|
enctype="multipart/form-data">
|
||||||
|
@ -42,8 +42,7 @@
|
||||||
<article>
|
<article>
|
||||||
<details>
|
<details>
|
||||||
<summary>{% trans 'Email' %}</summary>
|
<summary>{% trans 'Email' %}</summary>
|
||||||
<form action="{% url 'users:register' %}?next={{ request.path }}"
|
<form action="{% url 'users:register' %}" method="post">
|
||||||
method="post">
|
|
||||||
<input value="{{ request.user.username }}" type="hidden" name="username" />
|
<input value="{{ request.user.username }}" type="hidden" name="username" />
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label>
|
<label>
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
</header>
|
</header>
|
||||||
<div>
|
<div>
|
||||||
{% if request.user.is_authenticated %}
|
{% 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 %}
|
{% elif allow_any_site %}
|
||||||
<div role="group">
|
<div role="group">
|
||||||
{% if enable_email %}
|
{% if enable_email %}
|
||||||
|
|
|
@ -17,14 +17,14 @@
|
||||||
<h4>{% trans 'Verify Your Email' %}</h4>
|
<h4>{% trans 'Verify Your Email' %}</h4>
|
||||||
{% if success %}
|
{% if success %}
|
||||||
<p>
|
<p>
|
||||||
{{ request.user.email }} {% trans "verified successfully." %}
|
{{ request.user.email }} {% trans "Verified successfully." %}
|
||||||
<br>
|
<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>
|
</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>
|
<p>
|
||||||
{{ error }}
|
{{ error }}
|
||||||
<a href="{% url 'users:login' %}">{% trans "login again" %}</a>
|
<a href="{% url 'users:login' %}">{% trans "Login again" %}</a>
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</article>
|
</article>
|
||||||
|
|
|
@ -20,11 +20,11 @@
|
||||||
<h4>{% trans "Welcome" %}</h4>
|
<h4>{% trans "Welcome" %}</h4>
|
||||||
<p>
|
<p>
|
||||||
{% blocktrans %}
|
{% 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 %}
|
{% endblocktrans %}
|
||||||
</p>
|
</p>
|
||||||
<form action="{{ request.session.next_url | default:'/' }}" method="get">
|
<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>
|
</form>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -131,7 +131,7 @@ def register(request: AuthedHttpRequest):
|
||||||
auth_login(request, new_user)
|
auth_login(request, new_user)
|
||||||
return render(request, "users/welcome.html")
|
return render(request, "users/welcome.html")
|
||||||
else:
|
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
|
# use verified email if presents for new account creation
|
||||||
if verified_account and verified_account.platform == Platform.EMAIL:
|
if verified_account and verified_account.platform == Platform.EMAIL:
|
||||||
|
|
Loading…
Add table
Reference in a new issue