[acl] more checks in connected decorator
This commit is contained in:
parent
1087804e8a
commit
2f283db823
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
from starlette.authentication import UnauthenticatedUser
|
||||||
|
|
||||||
""" Base ACL module that contains generic functions for domains ACL
|
""" Base ACL module that contains generic functions for domains ACL
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -8,7 +10,9 @@ def connected(func):
|
||||||
"""
|
"""
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
def caller(req, *args, **kwargs):
|
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 False
|
||||||
return func(req, **kwargs)
|
return func(req, **kwargs)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue