SGL avec une premiere implementation de SSO
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.
Binary file not shown.
Binary file not shown.
@@ -3,4 +3,4 @@ from django.apps import AppConfig
|
||||
|
||||
class AuthentificationConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "authentification"
|
||||
name = "authentification"
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,8 +3,6 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
# Create your models here.
|
||||
class Departement(models.Model):
|
||||
"""Modèle représentant un département."""
|
||||
|
||||
@@ -14,7 +12,6 @@ class Departement(models.Model):
|
||||
"""Retourne une représentation en chaîne de caractères du dép."""
|
||||
return self.nom_departement
|
||||
|
||||
|
||||
class Profile(models.Model):
|
||||
"""Modèle représentant le profil utilisateur.
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -5,7 +5,6 @@ la gestion de l'accès des utilisateurs aux différentes pages.
|
||||
"""
|
||||
|
||||
from django import template
|
||||
# from authentification.models import Profile
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@@ -13,24 +12,3 @@ register = template.Library()
|
||||
def has_group(user, group_name):
|
||||
"""Vérifiez si un utilisateur appartient à un groupe spécifique."""
|
||||
return user.groups.filter(name=group_name).exists()
|
||||
|
||||
|
||||
# On recupère l'utilisateur et le produit
|
||||
## Si l'utilisateur n'est pas le chef d'un département, afficher simplement ses
|
||||
# demandes
|
||||
## Si l'utilisateur est un chef de département
|
||||
### Afficher la liste de ses demandes
|
||||
### Verifier pour chaque demande que l'utilisateur appartient à son departement
|
||||
#### Si oui, afficher le produit
|
||||
#### Si non, ne pas afficher le produit
|
||||
|
||||
|
||||
# @register.filter
|
||||
# def affichage_demande(user, demande):
|
||||
# if user.profile.chef_departement:
|
||||
# chef_profile = Profile.objects.get(id=user.profile)
|
||||
# departement = chef_profile.departement
|
||||
# ids_profils_departement = Profile.objects.filter(departement=departement)["id"]
|
||||
|
||||
# return demande.user_id in ids_profils_departement
|
||||
# return user.profile.id == demande.user_id
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,32 +1,18 @@
|
||||
"""Vues pour l'authentification des utilisateurs."""
|
||||
|
||||
from django.shortcuts import render, redirect
|
||||
from django.contrib.auth import authenticate, login, logout
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import logout
|
||||
from django.shortcuts import redirect
|
||||
from django.urls import reverse_lazy
|
||||
|
||||
from SGL.views import index
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
def connexion(request):
|
||||
"""Gérez la connexion des utilisateurs."""
|
||||
if request.method == "POST":
|
||||
username = request.POST["username"]
|
||||
password = request.POST["password"]
|
||||
|
||||
user = authenticate(username=username, password=password)
|
||||
|
||||
if user is not None:
|
||||
login(request, user)
|
||||
return redirect(index)
|
||||
messages.error(request, "Nom d'utilisateur ou mot de passe incorrect.")
|
||||
|
||||
return render(
|
||||
request,
|
||||
"authentification/login.html",
|
||||
)
|
||||
"""Redirige vers le serveur SSO pour l'authentification."""
|
||||
return redirect(reverse_lazy("simple-sso-login"))
|
||||
|
||||
|
||||
def deconnexion(request):
|
||||
"""Gérez la déconnexion des utilisateurs."""
|
||||
logout(request)
|
||||
return redirect("authentification:login")
|
||||
return redirect(settings.SSO_LOGOUT_URL)
|
||||
Binary file not shown.
Reference in New Issue
Block a user