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