Sign out helpers¶
To use features described on this page, you must also add a logout view for your provider:
from allauth_cas.views import CASLogoutView
logout = CASLogoutView.adapter_view(MyCASAdapter)
Suggest logout¶
Sending message¶
Using the method below, you can emit a message to suggest users to logout of the CAS server.
-
CASProvider.add_message_suggest_caslogout(request, next_page=None, level=None)¶ Add a message with a link for the user to logout of the CAS server.
It uses the template
socialaccount/messages/suggest_caslogout.html, with theproviderand thelogout_urlas context.Parameters: - request – The request to which the message is added.
- next_page (optional) – Added to the logout link for the CAS server
to redirect the user to this url.
Default:
request.get_full_path() - level – The message level. Default:
messages.INFO
Sending message at user logout¶
When the user signs out your application, this message can be sent automatically using the following settings.
The message contains a logout link for the last used CAS server during the session.
In your settings:
SOCIALACCOUNT_PROVIDERS = {
# …
'<provider id>': {
# …
'MESSAGE_SUGGEST_CASLOGOUT_ON_LOGOUT': True,
# Optional. By default, messages.INFO
'MESSAGE_SUGGEST_CASLOGOUT_ON_LOGOUT_LEVEL': messages.WARNING,
},
}
If you need more control over the sending of the message, you can use the methods below of the provider class.
-
CASProvider.message_suggest_caslogout_on_logout(request)¶ Indicates whether the logout message should be sent on user logout.
By default, it returns
settings.SOCIALACCOUNT_PROVIDERS[self.id]['MESSAGE_SUGGEST_CASLOGOUT_ON_LOGOUT']orFalse.Notes
The
requestargument is the one trigerring the emission of the signaluser_logged_out.
-
CASProvider.message_suggest_caslogout_on_logout_level(request)¶ Level of the logout message issued on user logout.
By default, it returns
settings.SOCIALACCOUNT_PROVIDERS[self.id]['MESSAGE_SUGGEST_CASLOGOUT_ON_LOGOUT_LEVEL']ormessages.INFO.Notes
The
requestargument is the one trigerring the emission of the signaluser_logged_out.
Redirection after CAS logout¶
An url is always given for the CAS server to redirect the user to your application.
The target of this redirection is:
- If the link is created on user logout (using above configuration):
- if present, the url pointed by the GET parameter
next, which should be the url the user has just landed after being logged out;- otherwise, the value returned by
ACCOUNT_ADAPTER.get_logout_redirect_url().- If the link is created using
add_message_suggest_caslogout():
- if present, the value of the parameter
next_page;- otherwise, the url of the current page.
- Otherwise,
ACCOUNT_ADAPTER.get_logout_redirect_url().
Note
If no redirection happens, you should check the version declared by the
CASAdapter class corresponds to the CAS server one.