From 358cf35790740619c67100d866037826c23ddbc6 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 30 Jun 2026 23:06:43 +0200 Subject: [PATCH] Vraie page de connexion app (non-staff) + deconnexion --- compta/templates/compta/base.html | 6 +++- compta/templates/registration/login.html | 42 ++++++++++++++++++++++++ config/settings.py | 6 ++-- config/urls.py | 3 ++ 4 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 compta/templates/registration/login.html diff --git a/compta/templates/compta/base.html b/compta/templates/compta/base.html index 7f34b1c..6e4451a 100644 --- a/compta/templates/compta/base.html +++ b/compta/templates/compta/base.html @@ -55,7 +55,11 @@ Déclaration TVA + Saisir Importer - Admin + {% if user.is_staff %}Admin{% endif %} +
+ {% csrf_token %} + +

{{ entreprise.nom }}

diff --git a/compta/templates/registration/login.html b/compta/templates/registration/login.html new file mode 100644 index 0000000..b438d85 --- /dev/null +++ b/compta/templates/registration/login.html @@ -0,0 +1,42 @@ + + + + + +JB Compta — Connexion + + + +
+

JB Compta

+
Connexion à ton espace comptable.
+ + {% if form.errors %} +
Identifiant ou mot de passe incorrect. Vérifie aussi que ton compte est actif.
+ {% endif %} + +
+ {% csrf_token %} + + {{ form.username }} + + {{ form.password }} + + +
+
+ + diff --git a/config/settings.py b/config/settings.py index ec661a3..1efdacd 100644 --- a/config/settings.py +++ b/config/settings.py @@ -106,5 +106,7 @@ STORAGES = { DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" -# Redirections de connexion vers l'admin -LOGIN_URL = "/admin/login/" +# Connexion via la page de l'app (ouverte à tout utilisateur actif, pas seulement staff) +LOGIN_URL = "/login/" +LOGIN_REDIRECT_URL = "/dashboard/" +LOGOUT_REDIRECT_URL = "/login/" diff --git a/config/urls.py b/config/urls.py index f0ad67d..458c7af 100644 --- a/config/urls.py +++ b/config/urls.py @@ -1,4 +1,5 @@ from django.contrib import admin +from django.contrib.auth import views as auth_views from django.urls import path, include from django.views.generic import RedirectView @@ -8,6 +9,8 @@ admin.site.index_title = "Gestion de la micro-entreprise" urlpatterns = [ path("", RedirectView.as_view(url="/dashboard/", permanent=False)), + path("login/", auth_views.LoginView.as_view(), name="login"), + path("logout/", auth_views.LogoutView.as_view(), name="logout"), path("admin/", admin.site.urls), path("", include("compta.urls")), ]