|
|
|
@ -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():
|
|
|
|
|