[acl] more checks in connected decorator

This commit is contained in:
Maxime Alves LIRMM 2020-07-10 12:53:25 +02:00
parent 1087804e8a
commit 2f283db823
1 changed files with 5 additions and 1 deletions

View File

@ -1,5 +1,7 @@
#!/usr/bin/env python3
from functools import wraps
from starlette.authentication import UnauthenticatedUser
""" Base ACL module that contains generic functions for domains ACL
"""
@ -8,7 +10,9 @@ def connected(func):
"""
@wraps(func)
def caller(req, *args, **kwargs):
if not hasattr(req.user, 'is_authenticated'):
if (not hasattr(req, 'user')
or type(req.user) == UnauthenticatedUser
or not hasattr(req.user, 'is_authenticated')):
return False
return func(req, **kwargs)