refactor: improve code formatting and organization across multiple files
This commit is contained in:
@@ -25,17 +25,25 @@ async def login(credentials: LoginRequest) -> AuthResponse:
|
||||
return issue_token_for_user(user)
|
||||
|
||||
|
||||
@router.post("/register", response_model=AuthResponse, status_code=status.HTTP_201_CREATED)
|
||||
@router.post(
|
||||
"/register", response_model=AuthResponse, status_code=status.HTTP_201_CREATED
|
||||
)
|
||||
async def register(payload: RegisterRequest) -> AuthResponse:
|
||||
try:
|
||||
user = register_user(payload.username, payload.password, payload.full_name)
|
||||
except ValueError as exc:
|
||||
message = str(exc)
|
||||
status_code = status.HTTP_409_CONFLICT if "exists" in message else status.HTTP_400_BAD_REQUEST
|
||||
status_code = (
|
||||
status.HTTP_409_CONFLICT
|
||||
if "exists" in message
|
||||
else status.HTTP_400_BAD_REQUEST
|
||||
)
|
||||
raise HTTPException(status_code=status_code, detail=message) from exc
|
||||
return issue_token_for_user(user)
|
||||
|
||||
|
||||
@router.get("/me", response_model=UserPublic)
|
||||
async def read_current_user(current_user: UserPublic = Depends(get_current_user)) -> UserPublic:
|
||||
async def read_current_user(
|
||||
current_user: UserPublic = Depends(get_current_user),
|
||||
) -> UserPublic:
|
||||
return current_user
|
||||
|
||||
Reference in New Issue
Block a user