2024-09-17 22:21:37 +02:00
|
|
|
from allauth.socialaccount.adapter import get_adapter
|
2017-07-25 18:31:42 +02:00
|
|
|
from allauth.account.utils import get_next_redirect_url
|
|
|
|
from allauth.socialaccount import providers
|
2024-01-25 15:33:24 +01:00
|
|
|
from django.contrib.auth.signals import user_logged_out
|
|
|
|
from django.dispatch import receiver
|
2017-07-25 18:31:42 +02:00
|
|
|
|
|
|
|
from . import CAS_PROVIDER_SESSION_KEY
|
|
|
|
|
|
|
|
|
|
|
|
@receiver(user_logged_out)
|
|
|
|
def cas_account_logout(sender, request, **kwargs):
|
|
|
|
provider_id = request.session.get(CAS_PROVIDER_SESSION_KEY)
|
|
|
|
|
2017-12-29 18:19:01 +01:00
|
|
|
if not provider_id:
|
2017-07-25 18:31:42 +02:00
|
|
|
return
|
|
|
|
|
2024-09-17 22:21:37 +02:00
|
|
|
provider = get_adapter(request).get_provider(request, provider_id)
|
2017-07-25 18:31:42 +02:00
|
|
|
|
2017-12-29 18:19:01 +01:00
|
|
|
if not provider.message_suggest_caslogout_on_logout(request):
|
2017-07-25 18:31:42 +02:00
|
|
|
return
|
|
|
|
|
2024-01-25 15:33:24 +01:00
|
|
|
next_page = get_next_redirect_url(request) or get_adapter(
|
|
|
|
request
|
|
|
|
).get_logout_redirect_url(request)
|
2017-07-25 18:31:42 +02:00
|
|
|
|
2017-12-29 18:19:01 +01:00
|
|
|
provider.add_message_suggest_caslogout(
|
2024-01-25 15:33:24 +01:00
|
|
|
request,
|
|
|
|
next_page=next_page,
|
2017-12-29 18:19:01 +01:00
|
|
|
level=provider.message_suggest_caslogout_on_logout_level(request),
|
|
|
|
)
|