Skip to content

Commit

Permalink
Fix PhoneNumberBanned producing status code 500 (#4570)
Browse files Browse the repository at this point in the history
# What this PR does
Handle PhoneNumberBanned as status code 403 instead of 500

## Which issue(s) this PR closes

Closes [issue link here]

<!--
*Note*: if you have more than one GitHub issue that this PR closes, be
sure to preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.

---------

Co-authored-by: Joey Orlando <[email protected]>
  • Loading branch information
mderynck and joeyorlando authored Jun 25, 2024
1 parent d583727 commit 63663b2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions engine/apps/api/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
FailedToStartVerification,
NumberAlreadyVerified,
NumberNotVerified,
PhoneNumberBanned,
ProviderNotSupports,
)
from apps.phone_notifications.phone_backend import PhoneBackend
Expand Down Expand Up @@ -478,6 +479,8 @@ def get_verification_code(self, request, pk) -> Response:
phone_backend.send_verification_sms(user)
except NumberAlreadyVerified:
return Response("Phone number already verified", status=status.HTTP_400_BAD_REQUEST)
except PhoneNumberBanned:
return Response("Phone number has been banned", status=status.HTTP_403_FORBIDDEN)
except FailedToStartVerification as e:
return handle_phone_notificator_failed(e)
except ProviderNotSupports:
Expand Down Expand Up @@ -505,6 +508,8 @@ def get_verification_call(self, request, pk) -> Response:
phone_backend.make_verification_call(user)
except NumberAlreadyVerified:
return Response("Phone number already verified", status=status.HTTP_400_BAD_REQUEST)
except PhoneNumberBanned:
return Response("Phone number has been banned", status=status.HTTP_403_FORBIDDEN)
except FailedToStartVerification as e:
return handle_phone_notificator_failed(e)
except ProviderNotSupports:
Expand Down

0 comments on commit 63663b2

Please sign in to comment.