Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# (c) 2018-2020
2# MPIB <https://www.mpib-berlin.mpg.de/>,
3# MPI-CBS <https://www.cbs.mpg.de/>,
4# MPIP <http://www.psych.mpg.de/>
5#
6# This file is part of Castellum.
7#
8# Castellum is free software; you can redistribute it and/or modify it
9# under the terms of the GNU Affero General Public License as published
10# by the Free Software Foundation; either version 3 of the License, or
11# (at your option) any later version.
12#
13# Castellum is distributed in the hope that it will be useful, but
14# WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16# Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public
19# License along with Castellum. If not, see
20# <http://www.gnu.org/licenses/>.
22import logging
24from .middlewares import set_last_active
26monitoring_logger = logging.getLogger('monitoring.auth')
29def set_last_active_on_login(sender, user, request, **kwargs):
30 set_last_active(request)
33def log_login(sender, user, request, **kwargs):
34 monitoring_logger.info('Login by {}'.format(user.pk))
37def log_failed_login(sender, credentials, request, **kwargs):
38 monitoring_logger.info('Failed login with username "{}"'.format(credentials['username']))
41def log_logout(sender, user, request, **kwargs):
42 if user: 42 ↛ exitline 42 didn't return from function 'log_logout', because the condition on line 42 was never false
43 monitoring_logger.info('Logout by {}'.format(user.pk))