Skip to content

Commit

Permalink
admin route schema roles
Browse files Browse the repository at this point in the history
  • Loading branch information
marceloarocha committed Nov 7, 2023
1 parent de41230 commit be0142d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions services/auth_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ def _auth_user(user, force_schema=None, default_roles=[]):
user_schema = force_schema
user_config = dict(user.config, **{"roles": roles + default_roles})

if RoleEnum.ADMIN.value in default_roles:
raise ValidationError(
"Permissão extra inválida",
"errors.unauthorizedUser",
status.HTTP_401_UNAUTHORIZED,
)

claims = {"schema": user_schema, "config": user_config}
access_token = create_access_token(identity=user.id, additional_claims=claims)
refresh_token = create_refresh_token(identity=user.id, additional_claims=claims)
Expand Down

0 comments on commit be0142d

Please sign in to comment.