Revision 67920ea0 snf-astakos-app/astakos/api/util.py
b/snf-astakos-app/astakos/api/util.py | ||
---|---|---|
80 | 80 |
raise faults.Unauthorized("Invalid X-Auth-Token") |
81 | 81 |
|
82 | 82 |
try: |
83 |
request.user = AstakosUser.objects.get(auth_token=token)
|
|
83 |
user = AstakosUser.objects.get(auth_token=token) |
|
84 | 84 |
except AstakosUser.DoesNotExist: |
85 | 85 |
raise faults.Unauthorized('Invalid X-Auth-Token') |
86 | 86 |
|
87 |
# Check if the user is active. |
|
88 |
if not user.is_active: |
|
89 |
raise faults.Unauthorized('User inactive') |
|
90 |
|
|
91 |
# Check if the token has expired. |
|
92 |
if user.token_expired(): |
|
93 |
raise faults.Unauthorized('Authentication expired') |
|
94 |
|
|
95 |
# Check if the user has accepted the terms. |
|
96 |
if not user.signed_terms: |
|
97 |
raise faults.Unauthorized('Pending approval terms') |
|
98 |
|
|
99 |
request.user = user |
|
87 | 100 |
return func(request, *args, **kwargs) |
88 | 101 |
return wrapper |
89 | 102 |
|
Also available in: Unified diff