Commit d200e8cf60ef0f889e0c97fb0e1cb0babedb2e4f
1 parent
ccb84a99
Exists in
master
and in
39 other branches
Allowing users to logout
Showing
1 changed file
with
8 additions
and
6 deletions
Show diff stats
colab/accounts/middleware.py
1 | -from django.core.urlresolvers import resolve | |
1 | + | |
2 | 2 | from django.shortcuts import redirect |
3 | 3 | |
4 | +VIEW_NAMES_ALLOWED = ('signup', 'Logout') | |
5 | + | |
4 | 6 | |
5 | 7 | class UserRegisterMiddleware(object): |
6 | 8 | |
7 | 9 | def process_view(self, request, view_func, view_args, view_kwargs): |
10 | + | |
11 | + if request.is_ajax(): | |
12 | + return | |
13 | + | |
8 | 14 | if not request.user.is_authenticated(): |
9 | 15 | return |
10 | 16 | |
11 | 17 | if not request.user.needs_update: |
12 | 18 | return |
13 | 19 | |
14 | - current_url = resolve(request.path_info).url_name | |
15 | - | |
16 | - if current_url not in ['signup']: | |
20 | + if view_func.__name__ not in VIEW_NAMES_ALLOWED: | |
17 | 21 | return redirect('signup') |
18 | - | |
19 | - return None | ... | ... |