Skip to content

Commit 81da51a

Browse files
committed
@sanderegg review: maybe_await
1 parent 9673113 commit 81da51a

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

services/web/server/src/simcore_service_webserver/security/_authz_access_model.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
https://b_logger.nodeswat.com/implement-access-control-in-node-js-8567e7b484d1
66
"""
77

8-
import inspect
98
import logging
109
from collections.abc import Awaitable, Callable
1110
from dataclasses import dataclass, field
1211
from typing import TypeAlias, TypedDict
1312

13+
from common_library.async_tools import maybe_await
1414
from models_library.products import ProductName
1515
from models_library.users import UserID
1616

@@ -114,13 +114,7 @@ async def can(
114114
if operation in role_access.check:
115115
check = role_access.check[operation]
116116
try:
117-
ok: bool
118-
coro_or_result = check(context)
119-
if inspect.isawaitable(coro_or_result):
120-
ok = await coro_or_result
121-
else:
122-
ok = coro_or_result
123-
return ok
117+
return await maybe_await(check(context))
124118

125119
except Exception: # pylint: disable=broad-except
126120
_logger.debug(

0 commit comments

Comments
 (0)