app.views_auth
Authentication views and routes for the Mail List Shield application.
This module defines the authentication-related routes including login, registration, logout, password reset, email confirmation, two-factor authentication, and Google OAuth integration.
Attributes
Functions
|
Load a user from the database by ID. |
Handle unauthorized access to protected routes. |
|
|
Log out the current user and redirect to the login page. |
|
The view function for the registration page. |
|
The view function for the login page. |
The view function for the two-factor authentication page. |
|
The view function for the email verification page. |
|
The view function for the password reset page. |
|
The view function for the password reset requested page. |
|
|
The view function for the set new password page. |
Get the Google SSO configuration. |
|
The view function for the Google login callback. |
Module Contents
- app.views_auth.load_user(user_id)[source]
Load a user from the database by ID.
This function is used by Flask-Login to reload the user object from the user ID stored in the session.
- Parameters:
user_id – The ID of the user to load.
- Returns:
The user object from the database corresponding to the user ID.
- Return type:
- app.views_auth.unauthorized_callback()[source]
Handle unauthorized access to protected routes.
Redirects unauthenticated users to the login page with the original destination preserved in the next parameter.
- Returns:
Redirect to the login page.
- Return type:
Response
- app.views_auth.logout()[source]
Log out the current user and redirect to the login page.
- Returns:
Redirect to the login page.
- Return type:
Response
- app.views_auth.register()[source]
The view function for the registration page.
Handles new user registration with reCAPTCHA verification.
- Returns:
The registration form or redirect to email confirmation.
- Return type:
Response
- app.views_auth.login()[source]
The view function for the login page.
Handles user authentication with optional Google OAuth and reCAPTCHA.
- Returns:
The login form or redirect to dashboard/two-factor auth.
- Return type:
Response
- app.views_auth.two_factor()[source]
The view function for the two-factor authentication page.
Verifies TOTP codes for users with two-factor authentication enabled.
- Returns:
The two-factor form or redirect to dashboard.
- Return type:
Response
- app.views_auth.email_confirmation_by_code()[source]
The view function for the email verification page.
Handles verification code entry and validation.
- Returns:
The email confirmation form or redirect to dashboard.
- Return type:
Response
- app.views_auth.password_reset()[source]
The view function for the password reset page.
Initiates the password reset process by sending a reset email.
- Returns:
The password reset form or redirect to confirmation page.
- Return type:
Response
- app.views_auth.password_reset_requested()[source]
The view function for the password reset requested page.
Shows a confirmation message after a password reset request.
- Returns:
The password reset requested confirmation page.
- Return type:
Response
- app.views_auth.set_new_password(token)[source]
The view function for the set new password page.
Validates the reset token and allows the user to set a new password.
- Parameters:
token (str) – The token from the forgot password email, used to verify the user.
- Returns:
The new password form or redirect to login.
- Return type:
Response
- app.views_auth.get_google_sso_config()[source]
Get the Google SSO configuration.
Fetches the OpenID Connect discovery document from Google.
- Returns:
The Google SSO configuration including endpoints.
- Return type:
dict
- app.views_auth.login_callback_google()[source]
The view function for the Google login callback.
This is the page that Google redirects to after the Google authentication attempt. Handles both existing users logging in and new user registration via Google OAuth.
- Returns:
Redirect to dashboard or login page based on authentication result.
- Return type:
Response