feat: login

This commit is contained in:
2025-01-14 15:44:50 -03:00
parent 3b006e7a63
commit 9b4e1cfca4
27 changed files with 210 additions and 51 deletions

View File

@@ -1,7 +1,13 @@
from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.forms import AuthenticationForm
def logout_view(request):
logout(request)
return redirect('login')
def login_view(request):
if request.method == 'POST':
form = AuthenticationForm(data=request.POST)
@@ -11,7 +17,7 @@ def login_view(request):
user = authenticate(username=username, password=password)
if user is not None:
login(request, user)
return redirect('home') # Substitua 'home' pelo nome da sua URL inicial
return redirect('home')
else:
pass
# Mensagem de erro: Credenciais inválidas