added login functionality
All checks were successful
Django Backend Validation / build (debian-latest, 3.10) (push) Successful in 13s
Django Backend Validation / build (debian-latest, 3.11) (push) Successful in 18s
Django Backend Validation / build (debian-latest, 3.12) (push) Successful in 16s
Django Backend Validation / build (ubuntu-latest, 3.12) (push) Successful in 15s
Django Backend Validation / build (ubuntu-latest, 3.10) (push) Successful in 14s
Django Backend Validation / build (ubuntu-latest, 3.11) (push) Successful in 14s
All checks were successful
Django Backend Validation / build (debian-latest, 3.10) (push) Successful in 13s
Django Backend Validation / build (debian-latest, 3.11) (push) Successful in 18s
Django Backend Validation / build (debian-latest, 3.12) (push) Successful in 16s
Django Backend Validation / build (ubuntu-latest, 3.12) (push) Successful in 15s
Django Backend Validation / build (ubuntu-latest, 3.10) (push) Successful in 14s
Django Backend Validation / build (ubuntu-latest, 3.11) (push) Successful in 14s
Signed-off-by: Jochen Mehlich <coding@jochenmehlich.de>
This commit is contained in:
parent
71549178ff
commit
01300ba54a
@ -8,29 +8,20 @@
|
|||||||
<h1 class="text-xl font-bold leading-tight tracking-tight text-gray-900 md:text-2xl dark:text-white">
|
<h1 class="text-xl font-bold leading-tight tracking-tight text-gray-900 md:text-2xl dark:text-white">
|
||||||
Sign in to your account
|
Sign in to your account
|
||||||
</h1>
|
</h1>
|
||||||
<form class="space-y-4 md:space-y-6" action="#">
|
<form class="space-y-4 md:space-y-6" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for="email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your email</label>
|
<label for="username" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your username</label>
|
||||||
<input type="email" name="email" id="email" class="bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="name@company.com" required="">
|
<input type="text" name="username" id="username" class="bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="fooboar" required="">
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Password</label>
|
<label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Password</label>
|
||||||
<input type="password" name="password" id="password" placeholder="••••••••" class="bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" required="">
|
<input type="password" name="password" id="password" placeholder="••••••••" class="bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" required="">
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center justify-between">
|
|
||||||
<div class="flex items-start">
|
|
||||||
<div class="flex items-center h-5">
|
|
||||||
<input id="remember" aria-describedby="remember" type="checkbox" class="w-4 h-4 border border-gray-300 rounded bg-gray-50 focus:ring-3 focus:ring-primary-300 dark:bg-gray-700 dark:border-gray-600 dark:focus:ring-primary-600 dark:ring-offset-gray-800" required="">
|
|
||||||
</div>
|
|
||||||
<div class="ml-3 text-sm">
|
|
||||||
<label for="remember" class="text-gray-500 dark:text-gray-300">Remember me</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<a href="#" class="text-sm font-medium text-primary-600 hover:underline dark:text-primary-500">Forgot password?</a>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="w-full text-white bg-primary-600 hover:bg-primary-700 focus:ring-4 focus:outline-none focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800">Sign in</button>
|
<button type="submit" class="w-full text-white bg-primary-600 hover:bg-primary-700 focus:ring-4 focus:outline-none focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800">Sign in</button>
|
||||||
<p class="text-sm font-light text-gray-500 dark:text-gray-400">
|
<p class="text-sm font-light text-gray-500 dark:text-gray-400">
|
||||||
Don’t have an account yet? <a href="#" class="font-medium text-primary-600 hover:underline dark:text-primary-500">Sign up</a>
|
Don’t have an account yet? <a href="#" class="font-medium text-primary-600 hover:underline dark:text-primary-500">Login</a>
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
6
zitate/forms.py
Normal file
6
zitate/forms.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from django import forms
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
class LoginForm(forms.Form):
|
||||||
|
username = forms.CharField(label="username", max_length=255)
|
||||||
|
password = forms.CharField(label="password", max_length=255, widget=forms.PasswordInput)
|
||||||
@ -1,4 +1,22 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
import django.contrib.auth as dauth
|
||||||
|
from django.shortcuts import redirect
|
||||||
|
|
||||||
|
from zitate.forms import LoginForm
|
||||||
|
|
||||||
|
|
||||||
def login(request):
|
def login(request):
|
||||||
return render(request, "login.html")
|
if request.method == "GET":
|
||||||
|
return render(request, "login.html")
|
||||||
|
elif request.method == "POST":
|
||||||
|
form = LoginForm(request.POST)
|
||||||
|
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:
|
||||||
|
form = LoginForm()
|
||||||
|
return render(request, "login.html", {"form": form})
|
||||||
Loading…
x
Reference in New Issue
Block a user