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

Binary file not shown.

Binary file not shown.

View File

@@ -1,13 +1,32 @@
<!DOCTYPE html>
{% load static %}
<html>
<head>
<title>Login</title>
</head>
<body>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Entrar</button>
</form>
</body>
<head>
<Title>Login Form</Title>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="stylesheet" href="{% static 'pico.css' %}">
<link rel="stylesheet" href="{% static 'login/css/login.css' %}">
</head>
<body>
<div class="c-form">
<h2>
<img src="{% static 'midia/logo.png' %}" width="140px">
</h2>
<div class="c-input">
<form method="post" class="c-inputBox">
{% csrf_token %}
{{ form.as_p }}
<div class="c-inputBox">
<input type="submit" name="" value="Entrar">
</div>
</form>
</div>
<!-- <p class="forgot">Forgot Password? <a href="#">Click Here</a></p> -->
</div>
</body>
</html>

View File

@@ -3,4 +3,5 @@ from . import views
urlpatterns = [
path('', views.login_view, name='login'),
path('logout', views.logout_view, name='logout'),
]

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