Skip to content

Commit 4058e1d

Browse files
committed
feat: ✨ Add COMBO role and authorization check in redeem_combo
1 parent 4b12047 commit 4058e1d

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎app/core/roles.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ class Roles:
1010
INFORMATION = "information"
1111
SPECIAL_POINT = "special_point"
1212
REVOCATION = "revocation"
13+
COMBO = "combo"
1314

1415
@staticmethod
1516
def get_roles() -> List[str]:
16-
return [Roles.ACCREDITATION, Roles.CHECKER, Roles.LAUNCH, Roles.SWAG, Roles.INFORMATION, Roles.SPECIAL_POINT, Roles.REVOCATION]
17+
return [Roles.ACCREDITATION, Roles.CHECKER, Roles.LAUNCH, Roles.SWAG, Roles.INFORMATION, Roles.SPECIAL_POINT, Roles.REVOCATION, Roles.COMBO]

‎app/routers/combos.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from fastapi import APIRouter, Depends, Response, status
44
from fastapi.responses import HTMLResponse
55
from app.auth.auth import get_current_active_user
6+
from app.core.roles import Roles
67
from app.models.combo import (
78
Combo,
89
ComboInDB,
@@ -122,6 +123,10 @@ async def redeem_combo(
122123
redeem: RedeemComboRequest,
123124
current_user: Annotated[UserInDB, Depends(get_current_active_user)],
124125
):
126+
if Roles.COMBO not in current_user.roles:
127+
return HTMLResponse(
128+
status_code=status.HTTP_401_UNAUTHORIZED, content="User not authorized"
129+
)
125130
participant = ParticipantService.get_by_control_code(
126131
redeem.participant_control_code
127132
)

‎app/services/point.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def get_by_participant_and_presentation(
5252
"participant_control_code": participant_control_code,
5353
"presentation": presentation_id,
5454
"disabled": False,
55+
"is_participation": False,
5556
}
5657
)
5758
if item is not None:

0 commit comments

Comments
 (0)