Skip to content

Commit

Permalink
Hook up the rate limit error to the waiting list
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaAutumn committed Sep 13, 2024
1 parent 864526d commit fcfad9e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions backend/src/appointment/routes/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def update_schedule(


@router.post('/public/availability', response_model=schemas.AppointmentOut)
@limiter.limit("10/minute")
@limiter.limit("20/minute")
def read_schedule_availabilities(
request: Request,
subscriber: Subscriber = Depends(get_subscriber_from_schedule_or_signed_url),
Expand Down Expand Up @@ -181,7 +181,7 @@ def read_schedule_availabilities(


@router.put('/public/availability/request')
@limiter.limit("10/minute")
@limiter.limit("20/minute")
def request_schedule_availability_slot(
request: Request,
s_a: schemas.AvailabilitySlotAttendee,
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,13 @@ export type PydanticExceptionDetail = {
msg: string,
type: string
}
export type FormExceptionDetail = {
id: string,
message: string,
status: number
}
export type PydanticException = {
detail?: PydanticExceptionDetail[];
detail?: FormExceptionDetail|PydanticExceptionDetail[];
}
export type Exception = {
status_code?: number;
Expand Down
16 changes: 10 additions & 6 deletions frontend/src/views/LoginView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ const handleFormError = (errObj: PydanticException) => {
const { detail } = errObj;
const fields = formRef.value.elements;
detail.forEach((err) => {
const name = err?.loc[1];
if (name) {
fields[name].setCustomValidity(err.ctx.reason);
}
});
if (Array.isArray(detail)) {
detail.forEach((err) => {
const name = err?.loc[1];
if (name) {
fields[name].setCustomValidity(err.ctx.reason);
}
});
} else {
loginError.value = detail.message;
}
// Finally report it!
formRef.value.reportValidity();
Expand Down

0 comments on commit fcfad9e

Please sign in to comment.