Log an audit message when a user successfully logs in

This commit is contained in:
Gergely Polonkai 2018-07-08 22:52:40 +02:00
parent aede5873d2
commit 23d0cd4b55

View File

@ -18,6 +18,7 @@
"""
from flask import current_app
from flask_login.signals import user_logged_in
from flask_security import Security, AnonymousUser as BaseAnonymousUser
security = Security()
@ -33,3 +34,13 @@ class AnonymousUser(BaseAnonymousUser):
"""
return current_app.timezone
@user_logged_in.connect
def login_handler(app, user):
"""Signal handler to be called when a user successfully logs in
"""
from .models import AuditLog
AuditLog.log(user, AuditLog.TYPE_LOGIN_SUCCESS)