Skip to content

Commit da704c8

Browse files
Merge remote-tracking branch 'origin/main' into modal
2 parents 9037781 + 50d2c1d commit da704c8

24 files changed

Lines changed: 2312 additions & 442 deletions

exceptions/http_exceptions.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from fastapi import HTTPException, status
2-
from utils.core.enums import ValidPermissions
32

43
class RateLimitError(HTTPException):
54
"""Raised when a client exceeds the allowed request rate."""
@@ -106,7 +105,7 @@ def __init__(self):
106105
class InvalidPermissionError(HTTPException):
107106
"""Raised when a user attempts to assign an invalid permission to a role"""
108107

109-
def __init__(self, permission: ValidPermissions):
108+
def __init__(self, permission: str):
110109
super().__init__(
111110
status_code=400,
112111
detail=f"Invalid permission: {permission}"
@@ -224,6 +223,33 @@ def __init__(self):
224223
)
225224

226225

226+
class MaxEmailsReachedError(HTTPException):
227+
"""Raised when an account already has the maximum number of email addresses."""
228+
def __init__(self):
229+
super().__init__(
230+
status_code=400,
231+
detail="Maximum number of email addresses reached"
232+
)
233+
234+
235+
class EmailNotVerifiedError(HTTPException):
236+
"""Raised when attempting to promote an unverified email address."""
237+
def __init__(self):
238+
super().__init__(
239+
status_code=400,
240+
detail="Email address is not verified"
241+
)
242+
243+
244+
class CannotRemovePrimaryEmailError(HTTPException):
245+
"""Raised when attempting to remove the primary email address."""
246+
def __init__(self):
247+
super().__init__(
248+
status_code=400,
249+
detail="Cannot remove primary email address"
250+
)
251+
252+
227253
class InvitationProcessingError(HTTPException):
228254
"""Raised when an error occurs during the processing of a valid invitation."""
229255
def __init__(self, detail: str = "Failed to process invitation. Please try again later."):

main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ async def credentials_exception_handler(request: Request, exc: CredentialsError)
127127
# Handle NeedsNewTokens by setting new tokens and redirecting to same page
128128
@app.exception_handler(NeedsNewTokens)
129129
async def needs_new_tokens_handler(request: Request, exc: NeedsNewTokens):
130+
# Preserve query string so GET routes with query params work after token refresh
131+
redirect_url = str(request.url)
130132
response = RedirectResponse(
131-
url=request.url.path, status_code=status.HTTP_307_TEMPORARY_REDIRECT)
133+
url=redirect_url, status_code=status.HTTP_307_TEMPORARY_REDIRECT)
132134
response.set_cookie(
133135
key="access_token",
134136
value=exc.access_token,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "fastapi-jinja2-postgres-webapp"
3-
version = "0.1.15"
3+
version = "0.1.16"
44
description = "A template webapp with a pure-Python FastAPI backend, frontend templating with Jinja2, and a Postgres database to power user auth"
55
readme = "README.md"
66
package-mode = false

0 commit comments

Comments
 (0)