fix: Correction de l'affichage du message d'erreur lors de l'authentification.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
45
authentification/migrations/0001_initial.py
Normal file
45
authentification/migrations/0001_initial.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# Generated by Django 5.2.15 on 2026-08-31 10:53
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Departement',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('nom', models.CharField(max_length=100)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Employe',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('matricule', models.CharField(blank=True, max_length=10, null=True, unique=True)),
|
||||
('fonction', models.CharField(blank=True, choices=[('directeur', 'Directeur'), ('assistant_direction', 'Assistante de direction'), ('assistant_technique_recherche', 'Assistant technique de recherche'), ('comptable', 'Comptable'), ('raf', 'RAF'), ('data_manager', 'Data Manager'), ('logisticien', 'Logisticien'), ('post_doctorant', 'Post-Doctorant'), ('qualiticien', 'Qualiticien'), ('technicien_surface', 'Technicien de surface'), ('chauffeur', 'Chauffeur')], max_length=50, null=True)),
|
||||
('date_embauche', models.DateField(blank=True, null=True)),
|
||||
('adresse', models.CharField(blank=True, max_length=100, null=True)),
|
||||
('telephone', models.CharField(blank=True, max_length=15, null=True)),
|
||||
('sexe', models.CharField(blank=True, choices=[('m', 'Masculin'), ('f', 'Féminin')], max_length=1, null=True)),
|
||||
('date_naissance', models.DateField(blank=True, null=True)),
|
||||
('CV', models.FileField(blank=True, null=True, upload_to='cv/')),
|
||||
('diplome', models.FileField(blank=True, null=True, upload_to='diplomes/')),
|
||||
('rib', models.FileField(blank=True, null=True, upload_to='rib/')),
|
||||
('photo', models.ImageField(blank=True, null=True, upload_to='photos/')),
|
||||
('casier_judiciaire', models.FileField(blank=True, null=True, upload_to='casier/')),
|
||||
('chef', models.BooleanField(default=False, verbose_name='Cet utilisateur est-il chef de ce département ?')),
|
||||
('departement', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='authentification.departement')),
|
||||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
]
|
||||
0
authentification/migrations/__init__.py
Normal file
0
authentification/migrations/__init__.py
Normal file
Binary file not shown.
BIN
authentification/migrations/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
authentification/migrations/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
@@ -1,13 +1,9 @@
|
||||
from decouple import config
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import authenticate, login, logout
|
||||
from django.shortcuts import render, redirect
|
||||
# from django.contrib import messages
|
||||
# from django.views.decorators.cache import never_cache
|
||||
# from django.views.decorators.http import require_http_methods
|
||||
from django.shortcuts import redirect, render
|
||||
|
||||
|
||||
# from django.contrib.auth import authenticate, login
|
||||
# from django.shortcuts import render, redirect
|
||||
|
||||
def login_view(request):
|
||||
if request.method == 'POST':
|
||||
username = request.POST.get('mail')
|
||||
@@ -15,57 +11,14 @@ def login_view(request):
|
||||
user = authenticate(request, username=username, password=password)
|
||||
if user is not None:
|
||||
login(request, user)
|
||||
next_url = request.GET.get('next') or request.POST.get('next') or '/'
|
||||
next_url = request.GET.get('next') or request.POST.get('next') or config("SIRH_LIEN")
|
||||
return redirect(next_url)
|
||||
else:
|
||||
messages.error(request, "L'adresse mail ou le mot de passe est invalide. Veuillez réessayer.")
|
||||
return render(request, 'authentification/login.html', {'error': 'Identifiants invalides'})
|
||||
return render(request, 'authentification/login.html')
|
||||
|
||||
# @never_cache
|
||||
# # @require_http_methods(["GET", "POST"])
|
||||
# def login_view(request):
|
||||
# """
|
||||
# Gère la connexion des utilisateurs avec redirection selon le rôle et
|
||||
# vérification de l'acceptation de la politique d'utilisation.
|
||||
# """
|
||||
# # if request.user.is_authenticated:
|
||||
# # next_url = request.GET.get('next', '')
|
||||
# # if next_url:
|
||||
# # return redirect(next_url)
|
||||
# # return redirect("gestion_conges:conge")
|
||||
|
||||
# if request.method == 'POST':
|
||||
# email = request.POST.get('mail')
|
||||
# password = request.POST.get('mot_de_passe')
|
||||
# # next_url = request.POST.get('next', '')
|
||||
|
||||
# if not (email and password):
|
||||
# messages.error(request, "Veuillez remplir tous les champs.")
|
||||
# return render(request, 'authentification/login.html')
|
||||
|
||||
# user = authenticate(request, username=email, password=password)
|
||||
|
||||
# if user is None or not user.is_active:
|
||||
# messages.error(request, "Nom d’utilisateur ou mot de passe incorrect ou le compte est inactif.")
|
||||
# return render(request, 'authentification/login.html')
|
||||
|
||||
# login(request, user)
|
||||
|
||||
# # if next_url:
|
||||
# # return redirect(next_url)
|
||||
|
||||
# # return redirect("gestion_conges:conge")
|
||||
|
||||
|
||||
# return render(
|
||||
# request,
|
||||
# 'authentification/login.html',
|
||||
# {
|
||||
# 'next': request.GET.get('next', ''),
|
||||
# }
|
||||
# )
|
||||
|
||||
def deconnexion_view(request):
|
||||
"""Gère la déconnexion de l'utilisateur."""
|
||||
logout(request)
|
||||
return redirect('login')
|
||||
return redirect('login')
|
||||
|
||||
Reference in New Issue
Block a user