dj22: use user.is_authenticated as a boolean (#36708)
This commit is contained in:
parent
21ce5ece53
commit
a14ced4d18
|
@ -160,7 +160,7 @@ def portal_agent_url(request):
|
|||
if 'authentic2' in settings.INSTALLED_APPS:
|
||||
portal_agents = [x for x in settings.KNOWN_SERVICES.get('combo', {}).values()
|
||||
if x.get('is-portal-agent')]
|
||||
if len(portal_agents) > 1 and request.user and request.user.is_authenticated() and request.user.ou_id:
|
||||
if len(portal_agents) > 1 and request.user and request.user.is_authenticated and request.user.ou_id:
|
||||
ou_slug = request.user.ou.slug
|
||||
for portal_agent in portal_agents:
|
||||
variables = portal_agent.get('variables') or {}
|
||||
|
|
|
@ -18,8 +18,8 @@ except ImportError:
|
|||
|
||||
class AnonymousAuthenticServiceUser(AnonymousUser):
|
||||
'''This virtual user hold permissions for other publik services'''
|
||||
def is_authenticated(self):
|
||||
return True
|
||||
is_authenticated = True
|
||||
is_anonymous = True
|
||||
|
||||
def has_perm(self, perm_or_perms, obj=None):
|
||||
return True
|
||||
|
@ -41,9 +41,8 @@ class AnonymousAuthenticServiceUser(AnonymousUser):
|
|||
class AnonymousAdminServiceUser(AnonymousUser):
|
||||
'''This virtual user hold permissions for other publik services'''
|
||||
is_staff = True
|
||||
|
||||
def is_authenticated(self):
|
||||
return True
|
||||
is_authenticated = True
|
||||
is_anonymous = True
|
||||
|
||||
def __unicode__(self):
|
||||
return 'Publik Service Admin'
|
||||
|
|
|
@ -19,7 +19,7 @@ from .environment.utils import Zone, get_installed_services
|
|||
from .forms import HoboForm, HoboUpdateForm, get_tenant_model
|
||||
|
||||
def is_superuser(u):
|
||||
if not u.is_authenticated():
|
||||
if not u.is_authenticated:
|
||||
return False
|
||||
if not u.is_superuser:
|
||||
raise PermissionDenied
|
||||
|
|
|
@ -46,7 +46,7 @@ def test_publik_authentication(tenant, settings):
|
|||
assert isinstance(result, tuple)
|
||||
assert len(result) == 2
|
||||
assert result[0].__class__ is rest_authentication.AnonymousAdminServiceUser
|
||||
assert result[0].is_authenticated()
|
||||
assert result[0].is_authenticated
|
||||
assert result[0].is_staff
|
||||
assert result[1] is None
|
||||
|
||||
|
|
Loading…
Reference in New Issue