diff --git a/halfapi/lib/acl.py b/halfapi/lib/acl.py index 15530e4..fa8edd2 100644 --- a/halfapi/lib/acl.py +++ b/halfapi/lib/acl.py @@ -14,9 +14,12 @@ def connected(fct=public): """ @wraps(fct) def caller(req, *args, **kwargs): + print(fct) + print(req.user) if (not hasattr(req, 'user') - or type(req.user) == UnauthenticatedUser + or isinstance(req.user, UnauthenticatedUser) or not hasattr(req.user, 'is_authenticated')): + print('Connected is false') return False return fct(req, **{**kwargs, **req.path_params}) diff --git a/halfapi/lib/routes.py b/halfapi/lib/routes.py index d9dbc29..433225f 100644 --- a/halfapi/lib/routes.py +++ b/halfapi/lib/routes.py @@ -37,12 +37,19 @@ def route_acl_decorator(fct: Callable, params: List[Dict]): @wraps(fct) async def caller(req: Request, *args, **kwargs): for param in params: - if param.get('acl') and param['acl'](req, *args, **kwargs): + if param.get('acl'): """ We merge the 'acl' and 'keys' kwargs values to let the decorated function know which ACL function answered True, and other parameters that you'd need """ + passed = param['acl'](req, *args, **kwargs) + if isinstance(passed, FunctionType): + passed = param['acl']()(req, *args, **kwargs) + + if not passed: + continue + return await fct( req, *args, **{