mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-12-22 18:00:17 +00:00
handle failed login
This commit is contained in:
parent
dffe974f9e
commit
0ce5183056
@ -24,6 +24,9 @@
|
||||
{% endif %}
|
||||
<h1>Tube Archivist</h1>
|
||||
<h2>Your Self Hosted YouTube Media Server</h2>
|
||||
{% if form_error %}
|
||||
<p class="danger-zone">Failed to login.</p>
|
||||
{% endif %}
|
||||
<form action="/login/" method="POST" name="login">
|
||||
{% csrf_token %}
|
||||
{% for field in form %}
|
||||
|
@ -148,12 +148,10 @@ class LoginView(View):
|
||||
|
||||
def get(self, request):
|
||||
"""handle get requests"""
|
||||
failed = bool(request.GET.get("failed"))
|
||||
colors = self.read_config()
|
||||
form = CustomAuthForm()
|
||||
context = {
|
||||
"colors": colors,
|
||||
"form": form,
|
||||
}
|
||||
context = {"colors": colors, "form": form, "form_error": failed}
|
||||
return render(request, "home/login.html", context)
|
||||
|
||||
@staticmethod
|
||||
@ -162,12 +160,11 @@ class LoginView(View):
|
||||
form = AuthenticationForm(data=request.POST)
|
||||
if form.is_valid():
|
||||
next_url = request.POST.get("next") or "home"
|
||||
print(f"next url: {next_url}")
|
||||
user = form.get_user()
|
||||
login(request, user)
|
||||
return redirect(next_url)
|
||||
|
||||
return redirect("login")
|
||||
return redirect("/login?failed=true")
|
||||
|
||||
@staticmethod
|
||||
def read_config():
|
||||
|
@ -542,6 +542,12 @@ button:hover {
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
.login-page button,
|
||||
.login-page .danger-zone {
|
||||
width: 210px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.login-links a {
|
||||
text-decoration: underline;
|
||||
margin: 30px 0;
|
||||
|
Loading…
Reference in New Issue
Block a user