2017-05-30 20:44:30 +02:00
|
|
|
from django.contrib import messages
|
|
|
|
from django.contrib.auth.signals import user_logged_in
|
|
|
|
from django.dispatch import receiver
|
2022-06-29 16:09:50 +02:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2017-05-30 20:44:30 +02:00
|
|
|
from django_cas_ng.signals import cas_user_authenticated
|
|
|
|
|
|
|
|
|
|
|
|
@receiver(user_logged_in)
|
|
|
|
def messages_on_out_login(request, user, **kwargs):
|
2018-10-06 12:35:49 +02:00
|
|
|
if user.backend.startswith("django.contrib.auth"):
|
|
|
|
msg = _("Connexion à GestioCOF réussie. Bienvenue {}.").format(
|
|
|
|
user.get_short_name()
|
2017-05-30 20:44:30 +02:00
|
|
|
)
|
|
|
|
messages.success(request, msg)
|
|
|
|
|
|
|
|
|
|
|
|
@receiver(cas_user_authenticated)
|
2018-11-25 00:37:22 +01:00
|
|
|
def messages_on_cas_login(request, user, **kwargs):
|
2018-10-06 12:35:49 +02:00
|
|
|
msg = _("Connexion à GestioCOF par CAS réussie. Bienvenue {}.").format(
|
|
|
|
user.get_short_name()
|
2017-05-30 20:44:30 +02:00
|
|
|
)
|
|
|
|
messages.success(request, msg)
|