forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresolver.py
More file actions
30 lines (26 loc) · 1.04 KB
/
resolver.py
File metadata and controls
30 lines (26 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from app import logger
from functions.auth_functions import is_admin
from functions.auth_wrappers import require_token
from schemas.is_user_admin.is_user_admin import IsUserAdmin
@require_token
def resolve_is_user_admin(self, info, **kwargs):
"""
This resolver checks to see if the user has any admin roles in any role that
they have assigned to their account.
:param self: None
:param info: Request Object
:param kwargs: Various arguments passed into function such as user_roles
:return: IsUserAdmin Type, with filled in field information
"""
user_id = kwargs.get("user_id")
user_roles = kwargs.get("user_roles")
for role in user_roles:
if is_admin(user_roles=user_roles, org_id=role.get("org_id")):
logger.info(
f"User: {user_id} checked for any admin roles, and found at least one."
)
return IsUserAdmin(True)
logger.info(
f"User: {user_id} checked for any admin roles, but did not find at least one."
)
return IsUserAdmin(False)