0001-dj22-use-user.is_authenticated-as-a-boolean-36708.patch
hobo/context_processors.py | ||
---|---|---|
160 | 160 |
if 'authentic2' in settings.INSTALLED_APPS: |
161 | 161 |
portal_agents = [x for x in settings.KNOWN_SERVICES.get('combo', {}).values() |
162 | 162 |
if x.get('is-portal-agent')] |
163 |
if len(portal_agents) > 1 and request.user and request.user.is_authenticated() and request.user.ou_id:
|
|
163 |
if len(portal_agents) > 1 and request.user and request.user.is_authenticated and request.user.ou_id: |
|
164 | 164 |
ou_slug = request.user.ou.slug |
165 | 165 |
for portal_agent in portal_agents: |
166 | 166 |
variables = portal_agent.get('variables') or {} |
hobo/logger.py | ||
---|---|---|
79 | 79 |
if not hasattr(record, 'user'): |
80 | 80 |
if (hasattr(request, 'user') |
81 | 81 |
and hasattr(request.user, 'is_authenticated') |
82 |
and request.user.is_authenticated()):
|
|
82 |
and request.user.is_authenticated): |
|
83 | 83 |
record.user = request.user |
84 | 84 |
else: |
85 | 85 |
record.user = None |
hobo/rest_authentication.py | ||
---|---|---|
18 | 18 | |
19 | 19 |
class AnonymousAuthenticServiceUser(AnonymousUser): |
20 | 20 |
'''This virtual user hold permissions for other publik services''' |
21 |
def is_authenticated(self):
|
|
22 |
return True
|
|
21 |
is_authenticated = True
|
|
22 |
is_anonymous = True
|
|
23 | 23 | |
24 | 24 |
def has_perm(self, perm_or_perms, obj=None): |
25 | 25 |
return True |
... | ... | |
41 | 41 |
class AnonymousAdminServiceUser(AnonymousUser): |
42 | 42 |
'''This virtual user hold permissions for other publik services''' |
43 | 43 |
is_staff = True |
44 | ||
45 |
def is_authenticated(self): |
|
46 |
return True |
|
44 |
is_authenticated = True |
|
45 |
is_anonymous = True |
|
47 | 46 | |
48 | 47 |
def __unicode__(self): |
49 | 48 |
return 'Publik Service Admin' |
hobo/views.py | ||
---|---|---|
19 | 19 |
from .forms import HoboForm, HoboUpdateForm, get_tenant_model |
20 | 20 | |
21 | 21 |
def is_superuser(u): |
22 |
if not u.is_authenticated():
|
|
22 |
if not u.is_authenticated: |
|
23 | 23 |
return False |
24 | 24 |
if not u.is_superuser: |
25 | 25 |
raise PermissionDenied |
tests_authentic/test_rest_authentication.py | ||
---|---|---|
46 | 46 |
assert isinstance(result, tuple) |
47 | 47 |
assert len(result) == 2 |
48 | 48 |
assert result[0].__class__ is rest_authentication.AnonymousAdminServiceUser |
49 |
assert result[0].is_authenticated()
|
|
49 |
assert result[0].is_authenticated |
|
50 | 50 |
assert result[0].is_staff |
51 | 51 |
assert result[1] is None |
52 | 52 | |
53 |
- |