get_current_user
Decodes a JWT token to validate credentials and retrieves the corresponding active user from the database, raising HTTP exceptions if the token is invalid, the user is missing, or the account is inactive.
def get_current_user(
session: SessionDep,
token: TokenDep
) - > User
Validates the provided JWT token to retrieve and return the currently authenticated user from the database. Raises a 403 error for invalid tokens, a 404 if the user does not exist, and a 400 if the user account is inactive.
Parameters
| Name | Type | Description |
|---|---|---|
| session | SessionDep | The database session dependency used to query the user record. |
| token | TokenDep | The encoded JWT access token used to identify and authenticate the user. |
Returns
| Type | Description |
|---|---|
User | The User model instance representing the authenticated requester. |