Total Complexity | 2 |
Total Lines | 13 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import random |
||
17 | class UserCookieMiddleWare(object): |
||
18 | """ |
||
19 | Middleware to set user cookie |
||
20 | If user is authenticated and there is no cookie, set the cookie, |
||
21 | If the user is not authenticated and the cookie remains, delete it |
||
22 | """ |
||
23 | |||
24 | def process_request(self, request): |
||
25 | try: |
||
26 | local.random |
||
27 | except AttributeError: |
||
28 | local.random = create_id(getattr(request.user, 'id'))[0] |
||
29 | local.client_ip = get_client_ip(request) |
||
30 |