routes.auth#
Module Contents#
Functions#
Endpoint to sign up a new user. |
|
Endpoint for user login. |
|
Endpoint to refresh an access token using a refresh token. |
|
Endpoint to log out a user by adding their refresh token to the blacklist. |
Data#
API#
- routes.auth.router = 'APIRouter(...)'#
- routes.auth.get_refresh_token = 'HTTPBearer(...)'#
- async routes.auth.signup(body: src.schemas.users.UserSchema, db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db))#
Endpoint to sign up a new user.
- Parameters:
body (UserSchema) – UserSchema instance containing user data.
db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
- Returns:
The newly created user.
- Return type:
- Raises:
HTTPException – If an account with the provided email already exists.
- async routes.auth.login(body: fastapi.security.OAuth2PasswordRequestForm = Depends(), db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db))#
Endpoint for user login.
- Parameters:
body (OAuth2PasswordRequestForm) – OAuth2PasswordRequestForm instance containing username and password.
db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
- Returns:
Access token and refresh token.
- Return type:
- Raises:
HTTPException – If the provided email is invalid or the password is incorrect.
- async routes.auth.refresh_token(credentials: fastapi.security.HTTPAuthorizationCredentials = Depends(get_refresh_token), db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db))#
Endpoint to refresh an access token using a refresh token.
- Parameters:
credentials (HTTPAuthorizationCredentials) – HTTPAuthorizationCredentials instance containing the refresh token.
db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
- Returns:
New access token and refresh token.
- Return type:
- Raises:
HTTPException – If the provided refresh token is invalid.
- async routes.auth.logout(user: src.entity.models.User = Depends(auth_service.get_current_user), db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db))#
Endpoint to log out a user by adding their refresh token to the blacklist.
- Parameters:
user (User) – The current authenticated user (dependency injection).
db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
- Returns:
A message indicating successful logout.
- Return type:
dict