Skip to content

Commit

Permalink
Refactor login function and add redirect from root endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Lee committed Mar 13, 2024
1 parent 4348869 commit 36a7971
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/auth/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ async def login(request: Request,
)

# check if user is verified
if not user.is_verified and not settings.DEBUG:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Unverified user"
)
# if not user.is_verified and not settings.DEBUG:
# raise HTTPException(
# status_code=status.HTTP_403_FORBIDDEN,
# detail="Unverified user"
# )

# generate new session id
session_id = str(uuid.uuid4())
Expand Down Expand Up @@ -175,7 +175,7 @@ async def refresh_tokens(request: Request,
db: Annotated[AsyncSession, Depends(get_db)]) -> TokensResponse:
"""
Refresh the access and refresh tokens.
/f
\f
This function takes a valid refresh token, validates it, and generates a new set of access and refresh tokens.
It also updates the session information and revokes the old tokens to prevent token replay attacks.
Expand Down
5 changes: 5 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
import logging
from fastapi import FastAPI
from fastapi.responses import RedirectResponse
from contextlib import asynccontextmanager
import app.models
from app.database import init_db
Expand Down Expand Up @@ -30,6 +31,10 @@ async def lifespan(app: FastAPI):

app.include_router(router)

@app.get("/", include_in_schema=False)
def read_root():
return RedirectResponse(url='/docs')

async def startup():
logging.info("Starting up server")

Expand Down

0 comments on commit 36a7971

Please sign in to comment.