Added setting to add a message after logout#104
Added setting to add a message after logout#104pythad wants to merge 2 commits intoyourlabs:masterfrom
Conversation
session_security/middleware.py
Outdated
|
|
||
| from datetime import datetime, timedelta | ||
|
|
||
| from django.contrib import messages |
There was a problem hiding this comment.
Should we not check that this app is installed ?
There was a problem hiding this comment.
It has been in Django core for quite a bit. Not sure for how long, but it was added to Git repo in 2009. It's definitely 1.8+ (django-session-security supported versions). So no, there is no need to check if this app has been installed.
There was a problem hiding this comment.
What happens if an app isn't using contrib.messages? Does the call fail silently? Error?
There was a problem hiding this comment.
By default django.contrib.messages is included into INSTALLED_APPS. So unless a developer deleted the package from INSTALLED_APPS everything will work. If there is no django.contrib.messages in INSTALLED_APPS an exception will be raised. But the default value of LOGOUT_MESSAGE is None, this means that by default we even don't need django.contrib.messages. And if a user will want to set LOGOUT_MESSAGE he will read the docs and see that it depends on django.contrib.messages. So the only scenario the exeption will be raised is when a user will specify LOGOUT_MESSAGE and delete django.contrib.messages from INSTALLED_APPS.
It's a common use case to provide a message after logout because of inactivity. This PR implements this feature.