Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit 0caefd4

Browse files
committed
Added a web_admin role
1 parent cbf0b77 commit 0caefd4

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

.gitignore

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,7 @@ dmypy.json
153153
# Cython debug symbols
154154
cython_debug/
155155

156-
# PyCharm
157-
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
158-
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
159-
# and can be added to the global gitignore or merged into this file. For a more nuclear
160-
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
161-
#.idea/
156+
# PyCharm and IntelliJ files
157+
.idea/
158+
162159

api/routes/security.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,19 @@ async def redirect_callback(code: str, state: Optional[str] = None):
267267
user_data.get('email', '')
268268
)
269269

270+
names = [group.name for group in user.groups]
271+
272+
# Check if the user is in the admin group to set the appropriate database role
273+
role = "web_user"
274+
if "admin" in names:
275+
role = "web_admin"
276+
270277
access_token = create_access_token(
271278
data={
272279
"sub": user.sub,
273-
"role": "web_user", # For PostgREST
280+
"role": role, # For PostgREST
274281
"groups": [group.id for group in user.groups],
275-
"group_names": [group.name for group in user.groups]
282+
"group_names": names
276283
}
277284
)
278285

0 commit comments

Comments
 (0)