tiny error message fix
This commit is contained in:
parent
92489e5e8a
commit
820c01097c
2 changed files with 82 additions and 30 deletions
|
|
@ -125,23 +125,10 @@ async def check_invite(
|
|||
)
|
||||
invite = result.scalar_one_or_none()
|
||||
|
||||
if not invite:
|
||||
# Return same error for not found, spent, and revoked to avoid information leakage
|
||||
if not invite or invite.status in (InviteStatus.SPENT, InviteStatus.REVOKED):
|
||||
return InviteCheckResponse(valid=False, error="Invite not found")
|
||||
|
||||
if invite.status == InviteStatus.SPENT:
|
||||
return InviteCheckResponse(
|
||||
valid=False,
|
||||
status=invite.status.value,
|
||||
error="This invite has already been used"
|
||||
)
|
||||
|
||||
if invite.status == InviteStatus.REVOKED:
|
||||
return InviteCheckResponse(
|
||||
valid=False,
|
||||
status=invite.status.value,
|
||||
error="This invite has been revoked"
|
||||
)
|
||||
|
||||
return InviteCheckResponse(valid=True, status=invite.status.value)
|
||||
|
||||
|
||||
|
|
@ -167,24 +154,13 @@ async def register(
|
|||
)
|
||||
invite = result.scalar_one_or_none()
|
||||
|
||||
if not invite:
|
||||
# Return same error for not found, spent, and revoked to avoid information leakage
|
||||
if not invite or invite.status in (InviteStatus.SPENT, InviteStatus.REVOKED):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Invalid invite code",
|
||||
)
|
||||
|
||||
if invite.status == InviteStatus.SPENT:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="This invite has already been used",
|
||||
)
|
||||
|
||||
if invite.status == InviteStatus.REVOKED:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="This invite has been revoked",
|
||||
)
|
||||
|
||||
# Check email not already taken
|
||||
existing_user = await get_user_by_email(db, user_data.email)
|
||||
if existing_user:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue