Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ciur committed Mar 26, 2024
1 parent a3b8d85 commit c80199c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion papermerge/core/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def get_current_user(
total_scopes.extend(
db.get_user_scopes_from_groups(
engine=engine,
user_id=token_data.user_id,
user_id=UUID(token_data.user_id),
groups=token_data.groups
)
)
Expand Down
10 changes: 6 additions & 4 deletions papermerge/core/db/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,15 @@ def update_user(

def get_user_scopes_from_groups(
engine: Engine,
user_id: str,
user_id: UUID,
groups: list[str]
) -> list[str]:
with Session(engine) as session:
db_user = session.scalars(
select(User).where(User.id == user_id)
).one()
db_user = session.get(User, user_id)

if db_user is None:
return []

db_groups = session.scalars(
select(Group).where(Group.name.in_(groups))
).all()
Expand Down

0 comments on commit c80199c

Please sign in to comment.