All checks were successful
Django Backend Validation / build (debian-latest, 3.11) (push) Successful in 19s
Django Backend Validation / build (debian-latest, 3.12) (push) Successful in 16s
Django Backend Validation / build (ubuntu-latest, 3.10) (push) Successful in 13s
Django Backend Validation / build (ubuntu-latest, 3.11) (push) Successful in 14s
Django Backend Validation / build (ubuntu-latest, 3.12) (push) Successful in 15s
Django Backend Validation / build (debian-latest, 3.10) (push) Successful in 14s
Signed-off-by: Jochen Mehlich <coding@jochenmehlich.de>
25 lines
937 B
Python
25 lines
937 B
Python
from django.shortcuts import render
|
|
import django.contrib.auth as dauth
|
|
from django.shortcuts import redirect
|
|
|
|
from zitate.forms import LoginForm
|
|
|
|
|
|
def login(request):
|
|
if request.method == "GET":
|
|
return render(request, "login.html")
|
|
elif request.method == "POST":
|
|
form = LoginForm(request.POST)
|
|
auth_type = request.POST.get("auth_type")
|
|
if auth_type == "form":
|
|
if form.is_valid():
|
|
username = form.cleaned_data["username"]
|
|
password = form.cleaned_data["password"]
|
|
user = dauth.authenticate(request, username=username, password=password)
|
|
if user is not None:
|
|
dauth.login(request, user)
|
|
return redirect("/")
|
|
else:
|
|
return render(request, "login.html", {"userError": True})
|
|
elif auth_type == "openid":
|
|
return render(request, "login.html") |