From 12eb91d0127e204f9d675283f684db22a8fd8e1f Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sun, 8 Jul 2018 22:52:40 +0200 Subject: [PATCH] Log an audit message when a user logs out --- calsocial/security.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/calsocial/security.py b/calsocial/security.py index 7a45923..a574ee6 100644 --- a/calsocial/security.py +++ b/calsocial/security.py @@ -18,7 +18,7 @@ """ from flask import current_app -from flask_login.signals import user_logged_in +from flask_login.signals import user_logged_in, user_logged_out from flask_security import Security, AnonymousUser as BaseAnonymousUser security = Security() @@ -44,3 +44,13 @@ def login_handler(app, user): from .models import AuditLog AuditLog.log(user, AuditLog.TYPE_LOGIN_SUCCESS) + + +@user_logged_out.connect +def logout_handler(app, user): + """Signal handler to be called when a user logs out + """ + + from .models import AuditLog + + AuditLog.log(user, AuditLog.TYPE_LOGOUT)