Source code for app.forms
"""WTForms form definitions for the Mail List Shield application.
This module defines Flask-WTF form classes for user authentication,
profile management, and API key creation.
"""
from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileRequired
from wtforms import (
StringField,
TextAreaField,
SubmitField,
PasswordField,
DateField,
IntegerField,
BooleanField,
RadioField,
)
from wtforms.validators import Email, NumberRange, InputRequired, DataRequired, Length
[docs]
class LoginForm(FlaskForm):
"""Form for user login.
Attributes:
email: Email address field with validation.
password: Password field with validation.
"""
[docs]
class RegisterForm(FlaskForm):
"""Form for new user registration.
Attributes:
email: Email address field with validation.
password: Password field with validation.
firstName: First name field (required).
lastName: Last name field (optional).
newsletter: Newsletter subscription checkbox.
"""
[docs]
class EmailConfirmationForm(FlaskForm):
"""Form for email confirmation code entry.
Contains 6 individual fields for each digit of the confirmation code.
Attributes:
code0-code5: Individual digit fields for the 6-digit confirmation code.
"""
[docs]
class ResetPassword(FlaskForm):
"""Form for requesting a password reset.
Attributes:
email: Email address field for the account to reset.
"""
[docs]
class SetNewPassword(FlaskForm):
"""Form for setting a new password after reset.
Attributes:
password: New password field with validation.
"""
[docs]
class ProfileDetailsForm(FlaskForm):
"""Form for updating user profile details.
Attributes:
firstName: First name field (required).
lastName: Last name field (optional).
newsletter: Newsletter subscription checkbox.
"""
[docs]
class TwoFactorAuthenticationForm(FlaskForm):
"""Form for two-factor authentication code entry.
Contains 6 individual fields for each digit of the TOTP code.
Attributes:
code0-code5: Individual digit fields for the 6-digit TOTP code.
"""
[docs]
class CreateAPIKeyForm(FlaskForm):
"""Form for creating a new API key.
Attributes:
label: Optional label for identifying the API key.
expires_at: Optional expiration date for the key.
submit: Submit button.
"""