annotate antispam/receivers.py @ 821:71db8076dc3d
Bandmap WIP: geocoding integrated with add form.
Add form works. Before submitting the form, client side JS makes
a geocode request to Google and populates hidden lat/lon fields
with the result. Successfully created a model instance on the
server side.
Still need to update admin dashboard, admin approval, and give
out badges for adding bands to the map. Once that is done, then
work on displaying the map with filtering.
author |
Brian Neal <bgneal@gmail.com> |
date |
Tue, 23 Sep 2014 20:40:31 -0500 |
parents |
988782c6ce6c |
children |
9d6c2ed2f348 |
rev |
line source |
bgneal@690
|
1 """ receivers.py - Signal receivers for login related events.
|
bgneal@690
|
2
|
bgneal@690
|
3 We log these events so that fail2ban can perform rate limiting.
|
bgneal@690
|
4
|
bgneal@690
|
5 """
|
bgneal@690
|
6 import logging
|
bgneal@690
|
7
|
bgneal@690
|
8 from django.contrib.auth.signals import (user_logged_in, user_logged_out,
|
bgneal@690
|
9 user_login_failed)
|
bgneal@690
|
10
|
bgneal@690
|
11
|
bgneal@690
|
12 # Get the auth logger that is monitored by fail2ban:
|
bgneal@690
|
13 logger = logging.getLogger('auth')
|
bgneal@690
|
14
|
bgneal@690
|
15
|
bgneal@690
|
16 def login_callback(sender, request, user, **kwargs):
|
bgneal@690
|
17 """Signal callback function for a user logging in."""
|
bgneal@690
|
18 logger.info('User login signal: %s', user.username)
|
bgneal@690
|
19
|
bgneal@690
|
20
|
bgneal@690
|
21 def logout_callback(sender, request, user, **kwargs):
|
bgneal@690
|
22 """Signal callback function for a user logging in."""
|
bgneal@690
|
23
|
bgneal@690
|
24 if user:
|
bgneal@690
|
25 logger.info('User logout signal: %s', user.username)
|
bgneal@690
|
26
|
bgneal@690
|
27 def login_failed_callback(sender, credentials, **kwargs):
|
bgneal@690
|
28 """Signal callback for a login failure event."""
|
bgneal@690
|
29 logger.error('User login failed signal from %s: %s', sender,
|
bgneal@690
|
30 credentials.get('username'))
|
bgneal@690
|
31
|
bgneal@690
|
32
|
bgneal@690
|
33 user_logged_in.connect(login_callback, dispatch_uid='antispam.receivers')
|
bgneal@690
|
34 user_logged_out.connect(logout_callback, dispatch_uid='antispam.receivers')
|
bgneal@690
|
35 user_login_failed.connect(login_failed_callback,
|
bgneal@690
|
36 dispatch_uid='antispam.receivers')
|