Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Add email verification and password reset functionality
Murtaza Nasir414c45a3f203
diff --git a/config/env.email.example b/config/env.email.examplenew file mode 100644index 00000000..80590f7d--- /dev/null+++ b/config/env.email.example@@ -0,0 +1,109 @@+###############################################################################+# Email Verification & Password Reset Configuration+###############################################################################++# Enable email verification for new user registrations.+# When enabled, new users must verify their email before full access.+# Default: false+ENABLE_EMAIL_VERIFICATION=false++# Require email verification to log in.+# Only effective when ENABLE_EMAIL_VERIFICATION=true.+# When true, users cannot log in until they verify their email.+# Default: false+REQUIRE_EMAIL_VERIFICATION=false++###############################################################################+# SMTP Configuration+###############################################################################++# SMTP server hostname (required for email functionality)+# Examples: smtp.gmail.com, smtp.sendgrid.net, smtp.mailgun.org+SMTP_HOST=smtp.gmail.com++# SMTP server port+# Common ports: 587 (TLS/STARTTLS), 465 (SSL), 25 (unencrypted)+# Default: 587+SMTP_PORT=587++# SMTP authentication username (usually your email address)++# SMTP authentication password+# For Gmail: Use an App Password (not your regular password)+# https://support.google.com/accounts/answer/185833+SMTP_PASSWORD=your-app-password++# Use TLS/STARTTLS encryption (recommended for port 587)+# Default: true+SMTP_USE_TLS=true++# Use SSL encryption (for port 465)+# Note: Only enable one of SMTP_USE_TLS or SMTP_USE_SSL+# Default: false+SMTP_USE_SSL=false++# Email address that appears in the "From" field+# Should be a valid email address, ideally matching your domain++# Display name that appears alongside the from address+# Default: Speakr+SMTP_FROM_NAME=Speakr++###############################################################################+# Provider-Specific Examples+###############################################################################++# --- Gmail ---+# SMTP_HOST=smtp.gmail.com+# SMTP_PORT=587+# SMTP_USE_TLS=true+# SMTP_PASSWORD=your-app-password # Generate at https://myaccount.google.com/apppasswords++# --- SendGrid ---+# SMTP_HOST=smtp.sendgrid.net+# SMTP_PORT=587+# SMTP_USE_TLS=true+# SMTP_USERNAME=apikey+# SMTP_PASSWORD=your-sendgrid-api-key++# --- Mailgun ---+# SMTP_HOST=smtp.mailgun.org+# SMTP_PORT=587+# SMTP_USE_TLS=true+# SMTP_PASSWORD=your-mailgun-password++# --- Amazon SES ---+# SMTP_HOST=email-smtp.us-east-1.amazonaws.com+# SMTP_PORT=587+# SMTP_USE_TLS=true+# SMTP_USERNAME=your-ses-smtp-username+# SMTP_PASSWORD=your-ses-smtp-password++# --- Microsoft 365 / Outlook ---+# SMTP_HOST=smtp.office365.com+# SMTP_PORT=587+# SMTP_USE_TLS=true+# SMTP_PASSWORD=your-password++###############################################################################+# Notes+###############################################################################++# Token Expiry Times:+# - Email verification links expire after 24 hours+# - Password reset links expire after 1 hour++# Migration Behavior:+# - Existing users are automatically marked as email_verified=true+# - New users (when feature is enabled) start as email_verified=false++# Security Recommendations:+# - Always use TLS or SSL encryption+# - Use app-specific passwords when available (Gmail, etc.)+# - Consider using a dedicated email service (SendGrid, Mailgun, SES)+# - Set a strong SECRET_KEY in your Flask configurationdiff --git a/src/api/auth.py b/src/api/auth.pyindex 7b751db1..1d9523f0 100644--- a/src/api/auth.py+++ b/src/api/auth.py@@ -30,6 +30,17 @@ from src.auth.sso import (link_sso_to_existing_user,update_user_profile_from_claims,)+from src.services.email import (+ is_email_verification_enabled,+ is_email_verification_required,+ is_smtp_configured,+ send_verification_email,+ send_password_reset_email,+ verify_email_token,+ verify_reset_token,+ can_resend_verification,+ can_resend_password_reset,+)# Create blueprintauth_bp = Blueprint('auth', __name__)@@ -153,9 +164,33 @@ def register():return render_template('register.html', title='Register', form=form)hashed_password = bcrypt.generate_password_hash(form.password.data).decode('utf-8')- user = User(username=form.username.data, email=form.email.data, password=hashed_password)++ # Set email_verified based on whether verification is enabled+ # If verification is enabled, new users start unverified+ # If disabled, new users are considered verified by default+ email_verified = not is_email_verification_enabled()++ user = User(+ username=form.username.data,+ email=form.email.data,+ password=hashed_password,+ email_verified=email_verified+ )db.session.add(user)db.session.commit()++ # Send verification email if enabled+ if is_email_verification_enabled() and is_smtp_configured():+ if send_verification_email(user):+ return render_template('auth/check_email.html',+ title='Check Your Email',+ email=user.email,+ action='verification')+ else:+ # Email failed to send, but account was created+ flash('Your account has been created, but we could not send a verification email. Please contact support.', 'warning')+ return redirect(url_for('auth.login'))+flash('Your account has been created! You can now log in.', 'success')return redirect(url_for('auth.login'))@@ -183,6 +218,16 @@ def login():if password_login_disabled and not user.is_admin:flash('Password login is disabled. Please sign in with SSO.', 'warning')elif bcrypt.check_password_hash(user.password, form.password.data):+ # Check email verification if required+ if is_email_verification_required() and not user.email_verified:+ # Store user email in session for resend functionality+ session['unverified_email'] = user.email+ return render_template('auth/check_email.html',+ title='Email Verification Required',+ email=user.email,+ action='verification_required',+ show_resend=True)+login_user(user, remember=form.remember.data)next_page = request.args.get('next')if not is_safe_url(next_page):@@ -331,6 +376,183 @@ def logout():return redirect(url_for('auth.login'))+# --- Email Verification Routes ---++@auth_bp.route('/verify-email/<token>')+def verify_email(token):+ """Verify email address using token from email link."""+ user_id = verify_email_token(token)++ if user_id is None:+ flash('The verification link is invalid or has expired.', 'danger')+ return redirect(url_for('auth.login'))++ user = db.session.get(User, user_id)+ if not user:+ flash('User not found.', 'danger')+ return redirect(url_for('auth.login'))++ if user.email_verified:+ flash('Your email has already been verified.', 'info')+ return redirect(url_for('auth.login'))++ # Verify the email+ user.email_verified = True+ user.email_verification_token = None # Clear the token+ db.session.commit()++ return render_template('auth/verify_success.html', title='Email Verified')+++@auth_bp.route('/resend-verification', methods=['POST'])+@rate_limit("3 per minute")+def resend_verification():+ """Resend verification email."""+ if not is_email_verification_enabled():+ flash('Email verification is not enabled.', 'danger')+ return redirect(url_for('auth.login'))++ if not is_smtp_configured():+ flash('Email service is not configured.', 'danger')+ return redirect(url_for('auth.login'))++ # Get email from session (set during failed login) or form+ email = session.get('unverified_email') or request.form.get('email')++ if not email:+ flash('Email address is required.', 'danger')+ return redirect(url_for('auth.login'))++ user = User.query.filter_by(email=email).first()++ if not user:+ # Don't reveal if user exists+ flash('If an account exists with this email, a verification link has been sent.', 'info')+ return redirect(url_for('auth.login'))++ if user.email_verified:+ flash('Your email has already been verified.', 'info')+ return redirect(url_for('auth.login'))++ # Check cooldown+ can_resend, remaining = can_resend_verification(user)+ if not can_resend:+ flash(f'Please wait {remaining} seconds before requesting another verification email.', 'warning')+ return render_template('auth/check_email.html',+ title='Check Your Email',+ email=email,+ action='verification_required',+ show_resend=True)++ if send_verification_email(user):+ flash('A new verification email has been sent.', 'success')+ else:+ flash('Failed to send verification email. Please try again later.', 'danger')++ return render_template('auth/check_email.html',+ title='Check Your Email',+ email=email,+ action='verification',+ show_resend=True)+++# --- Password Reset Routes ---++@auth_bp.route('/forgot-password', methods=['GET', 'POST'])+@rate_limit("5 per minute")+def forgot_password():+ """Show and handle forgot password form."""+ if current_user.is_authenticated:+ return redirect(url_for('recordings.index'))++ if not is_smtp_configured():+ flash('Password reset is not available. Please contact the administrator.', 'warning')+ return redirect(url_for('auth.login'))++ if request.method == 'POST':+ email = request.form.get('email')++ if not email:+ flash('Email address is required.', 'danger')+ return render_template('auth/forgot_password.html', title='Forgot Password')++ user = User.query.filter_by(email=email).first()++ # Always show the same message to prevent email enumeration+ if user:+ # Check if user has a password (not SSO-only)+ if user.password:+ # Check cooldown+ can_resend, remaining = can_resend_password_reset(user)+ if not can_resend:+ flash(f'Please wait {remaining} seconds before requesting another reset email.', 'warning')+ else:+ send_password_reset_email(user)++ flash('If an account exists with this email, a password reset link has been sent.', 'info')+ return render_template('auth/check_email.html',+ title='Check Your Email',+ email=email,+ action='password_reset')++ return render_template('auth/forgot_password.html', title='Forgot Password')+++@auth_bp.route('/reset-password/<token>', methods=['GET', 'POST'])+@rate_limit("10 per minute")+def reset_password(token):+ """Handle password reset form."""+ if current_user.is_authenticated:+ return redirect(url_for('recordings.index'))++ user_id = verify_reset_token(token)++ if user_id is None:+ flash('The password reset link is invalid or has expired.', 'danger')+ return redirect(url_for('auth.forgot_password'))++ user = db.session.get(User, user_id)+ if not user:+ flash('User not found.', 'danger')+ return redirect(url_for('auth.forgot_password'))++ if request.method == 'POST':+ password = request.form.get('password')+ confirm_password = request.form.get('confirm_password')++ if not password or not confirm_password:+ flash('Both password fields are required.', 'danger')+ return render_template('auth/reset_password.html', title='Reset Password', token=token)++ if password != confirm_password:+ flash('Passwords do not match.', 'danger')+ return render_template('auth/reset_password.html', title='Reset Password', token=token)++ # Validate password+ try:+ password_check(None, type('obj', (object,), {'data': password}))+ except ValidationError as e:+ flash(str(e), 'danger')+ return render_template('auth/reset_password.html', title='Reset Password', token=token)++ # Update password+ hashed_password = bcrypt.generate_password_hash(password).decode('utf-8')+ user.password = hashed_password+ user.password_reset_token = None # Clear the token+ user.password_reset_sent_at = None++ # Also verify email if not already verified+ if not user.email_verified:+ user.email_verified = True++ db.session.commit()++ flash('Your password has been reset. You can now log in with your new password.', 'success')+ return redirect(url_for('auth.login'))++ return render_template('auth/reset_password.html', title='Reset Password', token=token)++@auth_bp.route('/account', methods=['GET', 'POST'])@login_requireddef account():diff --git a/src/config/app_config.py b/src/config/app_config.pyindex cd2a6a64..0fa9e5b5 100644--- a/src/config/app_config.py+++ b/src/config/app_config.py@@ -67,6 +67,18 @@ AUDIO_BITRATE = os.environ.get('AUDIO_BITRATE', '128k') # For lossy codecs_unsupported_codecs_str = os.environ.get('AUDIO_UNSUPPORTED_CODECS', '')AUDIO_UNSUPPORTED_CODECS = {c.strip().lower() for c in _unsupported_codecs_str.split(',') if c.strip()}+# Email verification configuration+ENABLE_EMAIL_VERIFICATION = os.environ.get('ENABLE_EMAIL_VERIFICATION', 'false').lower() == 'true'+REQUIRE_EMAIL_VERIFICATION = os.environ.get('REQUIRE_EMAIL_VERIFICATION', 'false').lower() == 'true'+SMTP_HOST = os.environ.get('SMTP_HOST', '')+SMTP_PORT = int(os.environ.get('SMTP_PORT', '587'))+SMTP_USERNAME = os.environ.get('SMTP_USERNAME', '')+SMTP_PASSWORD = os.environ.get('SMTP_PASSWORD', '')+SMTP_USE_TLS = os.environ.get('SMTP_USE_TLS', 'true').lower() == 'true'+SMTP_USE_SSL = os.environ.get('SMTP_USE_SSL', 'false').lower() == 'true'+SMTP_FROM_ADDRESS = os.environ.get('SMTP_FROM_ADDRESS', '[email protected]')+SMTP_FROM_NAME = os.environ.get('SMTP_FROM_NAME', 'Speakr')+# Create chunking service at module level so it can be imported by processing.py# Always initialize the service - the needs_chunking() method will check ENABLE_CHUNKING# and return False when appropriate. This allows connectors with hard limits (e.g.,diff --git a/src/init_db.py b/src/init_db.pyindex ebfb164d..3849b8e6 100644--- a/src/init_db.py+++ b/src/init_db.py@@ -241,6 +241,46 @@ def initialize_database(app):# Naming templates featureif add_column_if_not_exists(engine, 'user', 'default_naming_template_id', 'INTEGER'):app.logger.info("Added default_naming_template_id column to user table")++ # Email verification fields+ email_verified_added = add_column_if_not_exists(engine, 'user', 'email_verified', 'BOOLEAN DEFAULT 0')+ if email_verified_added:+ app.logger.info("Added email_verified column to user table")+ # Set all existing users to email_verified=True (grandfathered)+ try:+ with engine.connect() as conn:+ conn.execute(text('UPDATE user SET email_verified = 1 WHERE email_verified = 0 OR email_verified IS NULL'))+ conn.commit()+ app.logger.info("Set email_verified=True for all existing users (grandfathered)")+ except Exception as e:+ app.logger.warning(f"Could not update existing users email_verified status: {e}")++ if add_column_if_not_exists(engine, 'user', 'email_verification_token', 'VARCHAR(200)'):+ app.logger.info("Added email_verification_token column to user table")+ if add_column_if_not_exists(engine, 'user', 'email_verification_sent_at', 'DATETIME'):+ app.logger.info("Added email_verification_sent_at column to user table")+ if add_column_if_not_exists(engine, 'user', 'password_reset_token', 'VARCHAR(200)'):+ app.logger.info("Added password_reset_token column to user table")+ if add_column_if_not_exists(engine, 'user', 'password_reset_sent_at', 'DATETIME'):+ app.logger.info("Added password_reset_sent_at column to user table")++ # Create indexes for token lookups (for faster token verification)+ try:+ inspector = inspect(engine)+ if 'user' in inspector.get_table_names():+ existing_indexes = [idx['name'] for idx in inspector.get_indexes('user')]+ if 'ix_user_email_verification_token' not in existing_indexes:+ with engine.connect() as conn:+ conn.execute(text('CREATE INDEX IF NOT EXISTS ix_user_email_verification_token ON user (email_verification_token)'))+ conn.commit()+ app.logger.info("Created index ix_user_email_verification_token on user.email_verification_token")+ if 'ix_user_password_reset_token' not in existing_indexes:+ with engine.connect() as conn:+ conn.execute(text('CREATE INDEX IF NOT EXISTS ix_user_password_reset_token ON user (password_reset_token)'))+ conn.commit()+ app.logger.info("Created index ix_user_password_reset_token on user.password_reset_token")+ except Exception as e:+ app.logger.warning(f"Could not create token indexes: {e}")if add_column_if_not_exists(engine, 'tag', 'naming_template_id', 'INTEGER'):app.logger.info("Added naming_template_id column to tag table")diff --git a/src/models/user.py b/src/models/user.pyindex 3157810f..1e456ce2 100644--- a/src/models/user.py+++ b/src/models/user.py@@ -42,6 +42,15 @@ class User(db.Model, UserMixin):# Transcription budget in seconds (None = unlimited)monthly_transcription_budget = db.Column(db.Integer, nullable=True)+ # Email verification fields+ email_verified = db.Column(db.Boolean, default=False)+ email_verification_token = db.Column(db.String(200), nullable=True, index=True)+ email_verification_sent_at = db.Column(db.DateTime, nullable=True)++ # Password reset fields+ password_reset_token = db.Column(db.String(200), nullable=True, index=True)+ password_reset_sent_at = db.Column(db.DateTime, nullable=True)+def __repr__(self):return f"User('{self.username}', '{self.email}')"diff --git a/src/services/email.py b/src/services/email.pynew file mode 100644index 00000000..a5f84d0d--- /dev/null+++ b/src/services/email.py@@ -0,0 +1,443 @@+"""+Email service for verification and password reset.++This module provides email functionality using Python's built-in smtplib.+All email features are opt-in via environment variables.+"""++import os+import smtplib+import logging+from email.mime.text import MIMEText+from email.mime.multipart import MIMEMultipart+from datetime import datetime, timedelta+from typing import Optional++from itsdangerous import URLSafeTimedSerializer, SignatureExpired, BadSignature+from flask import current_app, url_for++logger = logging.getLogger(__name__)++# Token expiry times+EMAIL_VERIFICATION_EXPIRY = 24 * 60 * 60 # 24 hours in seconds+PASSWORD_RESET_EXPIRY = 1 * 60 * 60 # 1 hour in seconds+++def get_email_config():+ """Get email configuration from environment variables."""+ return {+ 'enabled': os.environ.get('ENABLE_EMAIL_VERIFICATION', 'false').lower() == 'true',+ 'required': os.environ.get('REQUIRE_EMAIL_VERIFICATION', 'false').lower() == 'true',+ 'smtp_host': os.environ.get('SMTP_HOST', ''),+ 'smtp_port': int(os.environ.get('SMTP_PORT', '587')),+ 'smtp_username': os.environ.get('SMTP_USERNAME', ''),+ 'smtp_password': os.environ.get('SMTP_PASSWORD', ''),+ 'smtp_use_tls': os.environ.get('SMTP_USE_TLS', 'true').lower() == 'true',+ 'smtp_use_ssl': os.environ.get('SMTP_USE_SSL', 'false').lower() == 'true',+ 'from_address': os.environ.get('SMTP_FROM_ADDRESS', '[email protected]'),+ 'from_name': os.environ.get('SMTP_FROM_NAME', 'Speakr'),+ }+++def is_email_verification_enabled() -> bool:+ """Check if email verification is enabled."""+ return get_email_config()['enabled']+++def is_email_verification_required() -> bool:+ """Check if email verification is required for login."""+ config = get_email_config()+ return config['enabled'] and config['required']+++def is_smtp_configured() -> bool:+ """Check if SMTP settings are properly configured."""+ config = get_email_config()+ return bool(config['smtp_host'] and config['smtp_username'] and config['smtp_password'])+++def get_serializer(salt: str) -> URLSafeTimedSerializer:+ """Get a URL-safe timed serializer for token generation."""+ secret_key = current_app.config.get('SECRET_KEY', 'default-dev-key')+ return URLSafeTimedSerializer(secret_key, salt=salt)+++def generate_verification_token(user_id: int) -> str:+ """Generate an email verification token."""+ serializer = get_serializer('email-verification')+ return serializer.dumps(user_id)+++def generate_password_reset_token(user_id: int) -> str:+ """Generate a password reset token."""+ serializer = get_serializer('password-reset')+ return serializer.dumps(user_id)+++def verify_email_token(token: str) -> Optional[int]:+ """+ Verify an email verification token.++ Returns the user_id if valid, None otherwise.+ """+ serializer = get_serializer('email-verification')+ try:+ user_id = serializer.loads(token, max_age=EMAIL_VERIFICATION_EXPIRY)+ return user_id+ except SignatureExpired:+ logger.warning("Email verification token expired")+ return None+ except BadSignature:+ logger.warning("Invalid email verification token")+ return None+++def verify_reset_token(token: str) -> Optional[int]:+ """+ Verify a password reset token.++ Returns the user_id if valid, None otherwise.+ """+ serializer = get_serializer('password-reset')+ try:+ user_id = serializer.loads(token, max_age=PASSWORD_RESET_EXPIRY)+ return user_id+ except SignatureExpired:+ logger.warning("Password reset token expired")+ return None+ except BadSignature:+ logger.warning("Invalid password reset token")+ return None+++def _send_email(to_email: str, subject: str, html_body: str, text_body: str = None) -> bool:+ """+ Send an email using SMTP.++ Returns True if successful, False otherwise.+ """+ config = get_email_config()++ if not is_smtp_configured():+ logger.error("SMTP is not configured. Cannot send email.")+ return False++ try:+ msg = MIMEMultipart('alternative')+ msg['Subject'] = subject+ msg['From'] = f"{config['from_name']} <{config['from_address']}>"+ msg['To'] = to_email++ # Add plain text version+ if text_body:+ part1 = MIMEText(text_body, 'plain')+ msg.attach(part1)++ # Add HTML version+ part2 = MIMEText(html_body, 'html')+ msg.attach(part2)++ # Connect to SMTP server+ if config['smtp_use_ssl']:+ server = smtplib.SMTP_SSL(config['smtp_host'], config['smtp_port'])+ else:+ server = smtplib.SMTP(config['smtp_host'], config['smtp_port'])+ if config['smtp_use_tls']:+ server.starttls()++ server.login(config['smtp_username'], config['smtp_password'])+ server.sendmail(config['from_address'], to_email, msg.as_string())+ server.quit()++ logger.info(f"Email sent successfully to {to_email}")+ return True++ except smtplib.SMTPAuthenticationError as e:+ logger.error(f"SMTP authentication failed: {e}")+ return False+ except smtplib.SMTPException as e:+ logger.error(f"SMTP error sending email: {e}")+ return False+ except Exception as e:+ logger.error(f"Error sending email: {e}")+ return False+++def _get_email_template(content_html: str, content_text: str, subject: str) -> tuple[str, str]:+ """+ Wrap content in the Speakr email template.++ Returns (html_body, text_body)+ """+ # Get the base URL for the logo+ try:+ logo_url = url_for('static', filename='img/icon-192x192.png', _external=True)+ except RuntimeError:+ # Outside of request context, use a placeholder+ logo_url = ""++ html_body = f"""+<!DOCTYPE html>+<html>+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+</head>+<body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; line-height: 1.6; color: #1f2937; margin: 0; padding: 0; background-color: #e8eaed;">+ <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="background-color: #e8eaed;">+ <tr>+ <td style="padding: 40px 20px;">+ <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="600" style="max-width: 600px; margin: 0 auto;">+ <!-- Header -->+ <tr>+ <td style="background-color: #2563eb; padding: 32px 40px; border-radius: 12px 12px 0 0;">+ <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">+ <tr>+ <td>+ <!-- Logo and Brand -->+ <table role="presentation" cellspacing="0" cellpadding="0" border="0">+ <tr>+ <td style="vertical-align: middle; padding-right: 12px;">+ <img src="{logo_url}" alt="Speakr" width="44" height="44" style="display: block; border-radius: 8px;">+ </td>+ <td style="vertical-align: middle;">+ <h1 style="color: #ffffff; margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.5px;">Speakr</h1>+ </td>+ </tr>+ </table>+ </td>+ </tr>+ <tr>+ <td style="padding-top: 8px;">+ <p style="color: rgba(255,255,255,0.85); margin: 0; font-size: 14px;">AI-Powered Audio Transcription</p>+ </td>+ </tr>+ </table>+ </td>+ </tr>++ <!-- Content -->+ <tr>+ <td style="background-color: #ffffff; padding: 40px; border-left: 1px solid #e5e7eb; border-right: 1px solid #e5e7eb;">+ {content_html}+ </td>+ </tr>++ <!-- Footer -->+ <tr>+ <td style="background-color: #f8f9fa; padding: 24px 40px; border-radius: 0 0 12px 12px; border: 1px solid #e5e7eb; border-top: none;">+ <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">+ <tr>+ <td style="text-align: center;">+ <p style="color: #6b7280; font-size: 12px; margin: 0 0 8px 0;">+ This email was sent by Speakr. If you have questions, please contact your administrator.+ </p>+ <p style="color: #9ca3af; font-size: 11px; margin: 0;">+ © {datetime.utcnow().year} Speakr · AI-Powered Audio Transcription+ </p>+ </td>+ </tr>+ </table>+ </td>+ </tr>+ </table>+ </td>+ </tr>+ </table>+</body>+</html>+"""++ text_body = f"""+{subject}+{'=' * len(subject)}++{content_text}++---+This email was sent by Speakr - AI-Powered Audio Transcription.+If you have questions, please contact your administrator.+"""++ return html_body, text_body+++def send_verification_email(user) -> bool:+ """+ Send a verification email to a user.++ Args:+ user: User model instance++ Returns True if email was sent successfully, False otherwise.+ """+ from src.database import db++ if not is_email_verification_enabled():+ logger.debug("Email verification is disabled")+ return False++ if not is_smtp_configured():+ logger.warning("Cannot send verification email: SMTP not configured")+ return False++ # Generate token and store it+ token = generate_verification_token(user.id)+ user.email_verification_token = token+ user.email_verification_sent_at = datetime.utcnow()+ db.session.commit()++ # Build verification URL+ verify_url = url_for('auth.verify_email', token=token, _external=True)++ subject = "Verify your email address - Speakr"++ content_html = f"""+<h2 style="color: #1f2937; margin: 0 0 24px 0; font-size: 24px; font-weight: 600;">Verify Your Email Address</h2>++<p style="color: #374151; margin: 0 0 16px 0; font-size: 16px;">Hi {user.username},</p>++<p style="color: #374151; margin: 0 0 24px 0; font-size: 16px;">+ Welcome to Speakr! To complete your registration and start transcribing your audio recordings, please verify your email address.+</p>++<div style="text-align: center; margin: 32px 0;">+ <a href="{verify_url}" style="display: inline-block; background-color: #2563eb; color: #ffffff; text-decoration: none; padding: 14px 32px; border-radius: 8px; font-weight: 600; font-size: 16px;">Verify Email Address</a>+</div>++<p style="color: #6b7280; font-size: 14px; margin: 24px 0 8px 0;">Or copy and paste this link into your browser:</p>+<p style="word-break: break-all; color: #2563eb; font-size: 14px; margin: 0; padding: 12px; background-color: #f3f4f6; border-radius: 6px;">{verify_url}</p>++<div style="margin-top: 32px; padding-top: 24px; border-top: 1px solid #e5e7eb;">+ <p style="color: #9ca3af; font-size: 13px; margin: 0;">+ <strong>This link will expire in 24 hours.</strong><br>+ If you didn't create an account on Speakr, you can safely ignore this email.+ </p>+</div>+"""++ content_text = f"""Hi {user.username},++Welcome to Speakr! To complete your registration and start transcribing your audio recordings, please verify your email address.++Click here to verify: {verify_url}++This link will expire in 24 hours.++If you didn't create an account on Speakr, you can safely ignore this email."""++ html_body, text_body = _get_email_template(content_html, content_text, subject)+ return _send_email(user.email, subject, html_body, text_body)+++def send_password_reset_email(user) -> bool:+ """+ Send a password reset email to a user.++ Args:+ user: User model instance++ Returns True if email was sent successfully, False otherwise.+ """+ from src.database import db++ if not is_smtp_configured():+ logger.warning("Cannot send password reset email: SMTP not configured")+ return False++ # Generate token and store it+ token = generate_password_reset_token(user.id)+ user.password_reset_token = token+ user.password_reset_sent_at = datetime.utcnow()+ db.session.commit()++ # Build reset URL+ reset_url = url_for('auth.reset_password', token=token, _external=True)++ subject = "Reset your password - Speakr"++ content_html = f"""+<h2 style="color: #1f2937; margin: 0 0 24px 0; font-size: 24px; font-weight: 600;">Reset Your Password</h2>++<p style="color: #374151; margin: 0 0 16px 0; font-size: 16px;">Hi {user.username},</p>++<p style="color: #374151; margin: 0 0 24px 0; font-size: 16px;">+ We received a request to reset your Speakr account password. Click the button below to create a new password.+</p>++<div style="text-align: center; margin: 32px 0;">+ <a href="{reset_url}" style="display: inline-block; background-color: #2563eb; color: #ffffff; text-decoration: none; padding: 14px 32px; border-radius: 8px; font-weight: 600; font-size: 16px;">Reset Password</a>+</div>++<p style="color: #6b7280; font-size: 14px; margin: 24px 0 8px 0;">Or copy and paste this link into your browser:</p>+<p style="word-break: break-all; color: #2563eb; font-size: 14px; margin: 0; padding: 12px; background-color: #f3f4f6; border-radius: 6px;">{reset_url}</p>++<div style="margin-top: 32px; padding-top: 24px; border-top: 1px solid #e5e7eb;">+ <table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">+ <tr>+ <td style="width: 24px; vertical-align: top; padding-right: 12px;">+ <span style="font-size: 18px;">⚠️</span>+ </td>+ <td>+ <p style="color: #9ca3af; font-size: 13px; margin: 0;">+ <strong style="color: #6b7280;">This link will expire in 1 hour.</strong><br>+ If you didn't request a password reset, you can safely ignore this email. Your password will remain unchanged.+ </p>+ </td>+ </tr>+ </table>+</div>+"""++ content_text = f"""Hi {user.username},++We received a request to reset your Speakr account password. Click the link below to create a new password:++{reset_url}++This link will expire in 1 hour.++If you didn't request a password reset, you can safely ignore this email. Your password will remain unchanged."""++ html_body, text_body = _get_email_template(content_html, content_text, subject)+ return _send_email(user.email, subject, html_body, text_body)+++def can_resend_verification(user) -> tuple[bool, Optional[int]]:+ """+ Check if a verification email can be resent.++ Returns (can_resend, seconds_until_can_resend)+ """+ if not user.email_verification_sent_at:+ return True, None++ # Allow resend after 60 seconds+ cooldown = timedelta(seconds=60)+ time_since_last = datetime.utcnow() - user.email_verification_sent_at++ if time_since_last >= cooldown:+ return True, None++ remaining = (cooldown - time_since_last).seconds+ return False, remaining+++def can_resend_password_reset(user) -> tuple[bool, Optional[int]]:+ """+ Check if a password reset email can be resent.++ Returns (can_resend, seconds_until_can_resend)+ """+ if not user.password_reset_sent_at:+ return True, None++ # Allow resend after 60 seconds+ cooldown = timedelta(seconds=60)+ time_since_last = datetime.utcnow() - user.password_reset_sent_at++ if time_since_last >= cooldown:+ return True, None++ remaining = (cooldown - time_since_last).seconds+ return False, remainingdiff --git a/templates/auth/check_email.html b/templates/auth/check_email.htmlnew file mode 100644index 00000000..92bf9cb9--- /dev/null+++ b/templates/auth/check_email.html@@ -0,0 +1,127 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <meta name="robots" content="noindex, nofollow, noarchive, nosnippet, noimageindex">+ <title>{{ title }} - Speakr</title>+ <link rel="icon" href="{{ url_for('static', filename='img/favicon.ico') }}" type="image/svg+xml">+ <script src="{{ url_for('static', filename='vendor/js/tailwind.min.js') }}"></script>+ <link rel="stylesheet" href="{{ url_for('static', filename='vendor/css/fontawesome.min.css') }}">+ <link rel="stylesheet" href="{{ url_for('static', filename='css/styles.css') }}">++ {% include 'includes/loading_overlay.html' %}++ <script>+ function applyTheme() {+ if (!document.documentElement) return;+ const savedMode = localStorage.getItem('darkMode');+ const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;+ if (savedMode === 'true' || (savedMode === null && prefersDark)) {+ document.documentElement.classList.add('dark');+ } else {+ document.documentElement.classList.remove('dark');+ }+ const savedScheme = localStorage.getItem('colorScheme') || 'blue';+ const isDark = document.documentElement.classList.contains('dark');+ const themePrefix = isDark ? 'theme-dark-' : 'theme-light-';+ const themeClasses = ['blue', 'emerald', 'purple', 'rose', 'amber', 'teal'];+ themeClasses.forEach(theme => {+ document.documentElement.classList.remove(`theme-light-${theme}`);+ document.documentElement.classList.remove(`theme-dark-${theme}`);+ });+ if (savedScheme !== 'blue') {+ document.documentElement.classList.add(themePrefix + savedScheme);+ }+ }+ applyTheme();+ </script>+</head>+<body class="bg-[var(--bg-primary)] text-[var(--text-primary)]">+ <div class="container mx-auto px-4 sm:px-6 lg:px-8 py-6 flex flex-col min-h-screen">+ <header class="flex justify-between items-center mb-6 pb-4 border-b border-[var(--border-primary)]">+ <h1 class="text-3xl font-bold text-[var(--text-primary)]">+ <a href="{{ url_for('recordings.index') }}" class="flex items-center">+ <img src="{{ url_for('static', filename='img/favicon.ico') }}" alt="Speakr Logo" class="h-9 w-9 mr-2">+ Speakr+ </a>+ </h1>+ </header>++ <main class="flex-grow flex items-center justify-center">+ <div class="w-full max-w-md bg-[var(--bg-secondary)] p-8 rounded-xl shadow-lg border border-[var(--border-primary)]">+ {% with messages = get_flashed_messages(with_categories=true) %}+ {% if messages %}+ {% for category, message in messages %}+ <div class="mb-4 p-3 rounded-lg {% if category == 'success' %}bg-[var(--bg-success-light)] text-[var(--text-success-strong)]{% elif category == 'danger' %}bg-[var(--bg-danger-light)] text-[var(--text-danger-strong)]{% elif category == 'warning' %}bg-[var(--bg-warning-light)] text-[var(--text-warning-strong)]{% else %}bg-[var(--bg-info-light)] text-[var(--text-info-strong)]{% endif %}">+ {{ message }}+ </div>+ {% endfor %}+ {% endif %}+ {% endwith %}++ <div class="text-center">+ <div class="mb-6">+ <div class="w-20 h-20 mx-auto bg-[var(--bg-info-light)] rounded-full flex items-center justify-center">+ <i class="fas fa-envelope text-[var(--text-info-strong)] text-3xl"></i>+ </div>+ </div>++ {% if action == 'verification' %}+ <h2 class="text-2xl font-semibold text-[var(--text-primary)] mb-4">Check Your Email</h2>+ <p class="text-[var(--text-secondary)] mb-2">We've sent a verification link to:</p>+ <p class="text-[var(--text-primary)] font-medium mb-6">{{ email }}</p>+ <p class="text-[var(--text-muted)] text-sm mb-6">+ Click the link in the email to verify your account. The link will expire in 24 hours.+ </p>+ {% elif action == 'verification_required' %}+ <h2 class="text-2xl font-semibold text-[var(--text-primary)] mb-4">Email Verification Required</h2>+ <p class="text-[var(--text-secondary)] mb-2">Please verify your email address:</p>+ <p class="text-[var(--text-primary)] font-medium mb-6">{{ email }}</p>+ <p class="text-[var(--text-muted)] text-sm mb-6">+ Check your inbox for a verification email. If you haven't received it, you can request a new one.+ </p>+ {% elif action == 'password_reset' %}+ <h2 class="text-2xl font-semibold text-[var(--text-primary)] mb-4">Check Your Email</h2>+ <p class="text-[var(--text-secondary)] mb-2">If an account exists with this email:</p>+ <p class="text-[var(--text-primary)] font-medium mb-6">{{ email }}</p>+ <p class="text-[var(--text-muted)] text-sm mb-6">+ We've sent a password reset link. The link will expire in 1 hour.+ </p>+ {% endif %}++ {% if show_resend and (action == 'verification' or action == 'verification_required') %}+ <div class="mb-6">+ <form method="POST" action="{{ url_for('auth.resend_verification') }}">+ <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">+ <input type="hidden" name="email" value="{{ email }}">+ <button type="submit" class="text-[var(--text-accent)] hover:underline text-sm">+ <i class="fas fa-redo mr-1"></i> Resend verification email+ </button>+ </form>+ </div>+ {% endif %}++ <div class="pt-4 border-t border-[var(--border-secondary)]">+ <a href="{{ url_for('auth.login') }}" class="text-[var(--text-accent)] hover:underline">+ <i class="fas fa-arrow-left mr-1"></i> Back to Login+ </a>+ </div>+ </div>+ </div>+ </main>++ <footer class="text-center py-4 mt-8 text-xs text-[var(--text-light)] border-t border-[var(--border-primary)]">+ Speakr © {{ now.year }}+ </footer>+ </div>++ <script>+ document.addEventListener('DOMContentLoaded', function() {+ if (window.AppLoader) {+ AppLoader.waitForReady();+ }+ });+ </script>+</body>+</html>diff --git a/templates/auth/forgot_password.html b/templates/auth/forgot_password.htmlnew file mode 100644index 00000000..e3902827--- /dev/null+++ b/templates/auth/forgot_password.html@@ -0,0 +1,105 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <meta name="robots" content="noindex, nofollow, noarchive, nosnippet, noimageindex">+ <title>{{ title }} - Speakr</title>+ <link rel="icon" href="{{ url_for('static', filename='img/favicon.ico') }}" type="image/svg+xml">+ <script src="{{ url_for('static', filename='vendor/js/tailwind.min.js') }}"></script>+ <link rel="stylesheet" href="{{ url_for('static', filename='vendor/css/fontawesome.min.css') }}">+ <link rel="stylesheet" href="{{ url_for('static', filename='css/styles.css') }}">++ {% include 'includes/loading_overlay.html' %}++ <script>+ function applyTheme() {+ if (!document.documentElement) return;+ const savedMode = localStorage.getItem('darkMode');+ const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;+ if (savedMode === 'true' || (savedMode === null && prefersDark)) {+ document.documentElement.classList.add('dark');+ } else {+ document.documentElement.classList.remove('dark');+ }+ const savedScheme = localStorage.getItem('colorScheme') || 'blue';+ const isDark = document.documentElement.classList.contains('dark');+ const themePrefix = isDark ? 'theme-dark-' : 'theme-light-';+ const themeClasses = ['blue', 'emerald', 'purple', 'rose', 'amber', 'teal'];+ themeClasses.forEach(theme => {+ document.documentElement.classList.remove(`theme-light-${theme}`);+ document.documentElement.classList.remove(`theme-dark-${theme}`);+ });+ if (savedScheme !== 'blue') {+ document.documentElement.classList.add(themePrefix + savedScheme);+ }+ }+ applyTheme();+ </script>+</head>+<body class="bg-[var(--bg-primary)] text-[var(--text-primary)]">+ <div class="container mx-auto px-4 sm:px-6 lg:px-8 py-6 flex flex-col min-h-screen">+ <header class="flex justify-between items-center mb-6 pb-4 border-b border-[var(--border-primary)]">+ <h1 class="text-3xl font-bold text-[var(--text-primary)]">+ <a href="{{ url_for('recordings.index') }}" class="flex items-center">+ <img src="{{ url_for('static', filename='img/favicon.ico') }}" alt="Speakr Logo" class="h-9 w-9 mr-2">+ Speakr+ </a>+ </h1>+ </header>++ <main class="flex-grow flex items-center justify-center">+ <div class="w-full max-w-md bg-[var(--bg-secondary)] p-8 rounded-xl shadow-lg border border-[var(--border-primary)]">+ <h2 class="text-2xl font-semibold text-[var(--text-primary)] mb-2 text-center">Forgot Password</h2>+ <p class="text-[var(--text-muted)] text-sm text-center mb-6">+ Enter your email address and we'll send you a link to reset your password.+ </p>++ {% with messages = get_flashed_messages(with_categories=true) %}+ {% if messages %}+ {% for category, message in messages %}+ <div class="mb-4 p-3 rounded-lg {% if category == 'success' %}bg-[var(--bg-success-light)] text-[var(--text-success-strong)]{% elif category == 'danger' %}bg-[var(--bg-danger-light)] text-[var(--text-danger-strong)]{% elif category == 'warning' %}bg-[var(--bg-warning-light)] text-[var(--text-warning-strong)]{% else %}bg-[var(--bg-info-light)] text-[var(--text-info-strong)]{% endif %}">+ {{ message }}+ </div>+ {% endfor %}+ {% endif %}+ {% endwith %}++ <form method="POST" action="{{ url_for('auth.forgot_password') }}">+ <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">++ <div class="mb-6">+ <label for="email" class="block text-sm font-medium text-[var(--text-secondary)] mb-1">Email Address</label>+ <input type="email" id="email" name="email" required+ class="mt-1 block w-full rounded-md border-[var(--border-secondary)] shadow-sm focus:border-[var(--border-focus)] focus:ring-[var(--ring-focus)] focus:ring-opacity-50 bg-[var(--bg-input)] text-[var(--text-primary)]"+ placeholder="Enter your email address">+ </div>++ <div class="flex flex-col space-y-4">+ <button type="submit" class="w-full py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-[var(--text-button)] bg-[var(--bg-button)] hover:bg-[var(--bg-button-hover)] focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[var(--border-focus)]">+ <i class="fas fa-paper-plane mr-2"></i> Send Reset Link+ </button>++ <div class="text-center text-sm text-[var(--text-muted)]">+ <span>Remember your password?</span>+ <a href="{{ url_for('auth.login') }}" class="font-medium text-[var(--text-accent)] hover:underline">Back to Login</a>+ </div>+ </div>+ </form>+ </div>+ </main>++ <footer class="text-center py-4 mt-8 text-xs text-[var(--text-light)] border-t border-[var(--border-primary)]">+ Speakr © {{ now.year }}+ </footer>+ </div>++ <script>+ document.addEventListener('DOMContentLoaded', function() {+ if (window.AppLoader) {+ AppLoader.waitForReady();+ }+ });+ </script>+</body>+</html>diff --git a/templates/auth/reset_password.html b/templates/auth/reset_password.htmlnew file mode 100644index 00000000..f699bc8f--- /dev/null+++ b/templates/auth/reset_password.html@@ -0,0 +1,114 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <meta name="robots" content="noindex, nofollow, noarchive, nosnippet, noimageindex">+ <title>{{ title }} - Speakr</title>+ <link rel="icon" href="{{ url_for('static', filename='img/favicon.ico') }}" type="image/svg+xml">+ <script src="{{ url_for('static', filename='vendor/js/tailwind.min.js') }}"></script>+ <link rel="stylesheet" href="{{ url_for('static', filename='vendor/css/fontawesome.min.css') }}">+ <link rel="stylesheet" href="{{ url_for('static', filename='css/styles.css') }}">++ {% include 'includes/loading_overlay.html' %}++ <script>+ function applyTheme() {+ if (!document.documentElement) return;+ const savedMode = localStorage.getItem('darkMode');+ const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;+ if (savedMode === 'true' || (savedMode === null && prefersDark)) {+ document.documentElement.classList.add('dark');+ } else {+ document.documentElement.classList.remove('dark');+ }+ const savedScheme = localStorage.getItem('colorScheme') || 'blue';+ const isDark = document.documentElement.classList.contains('dark');+ const themePrefix = isDark ? 'theme-dark-' : 'theme-light-';+ const themeClasses = ['blue', 'emerald', 'purple', 'rose', 'amber', 'teal'];+ themeClasses.forEach(theme => {+ document.documentElement.classList.remove(`theme-light-${theme}`);+ document.documentElement.classList.remove(`theme-dark-${theme}`);+ });+ if (savedScheme !== 'blue') {+ document.documentElement.classList.add(themePrefix + savedScheme);+ }+ }+ applyTheme();+ </script>+</head>+<body class="bg-[var(--bg-primary)] text-[var(--text-primary)]">+ <div class="container mx-auto px-4 sm:px-6 lg:px-8 py-6 flex flex-col min-h-screen">+ <header class="flex justify-between items-center mb-6 pb-4 border-b border-[var(--border-primary)]">+ <h1 class="text-3xl font-bold text-[var(--text-primary)]">+ <a href="{{ url_for('recordings.index') }}" class="flex items-center">+ <img src="{{ url_for('static', filename='img/favicon.ico') }}" alt="Speakr Logo" class="h-9 w-9 mr-2">+ Speakr+ </a>+ </h1>+ </header>++ <main class="flex-grow flex items-center justify-center">+ <div class="w-full max-w-md bg-[var(--bg-secondary)] p-8 rounded-xl shadow-lg border border-[var(--border-primary)]">+ <h2 class="text-2xl font-semibold text-[var(--text-primary)] mb-2 text-center">Reset Password</h2>+ <p class="text-[var(--text-muted)] text-sm text-center mb-6">+ Enter your new password below.+ </p>++ {% with messages = get_flashed_messages(with_categories=true) %}+ {% if messages %}+ {% for category, message in messages %}+ <div class="mb-4 p-3 rounded-lg {% if category == 'success' %}bg-[var(--bg-success-light)] text-[var(--text-success-strong)]{% elif category == 'danger' %}bg-[var(--bg-danger-light)] text-[var(--text-danger-strong)]{% elif category == 'warning' %}bg-[var(--bg-warning-light)] text-[var(--text-warning-strong)]{% else %}bg-[var(--bg-info-light)] text-[var(--text-info-strong)]{% endif %}">+ {{ message }}+ </div>+ {% endfor %}+ {% endif %}+ {% endwith %}++ <form method="POST" action="{{ url_for('auth.reset_password', token=token) }}">+ <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">++ <div class="mb-4">+ <label for="password" class="block text-sm font-medium text-[var(--text-secondary)] mb-1">New Password</label>+ <input type="password" id="password" name="password" required+ class="mt-1 block w-full rounded-md border-[var(--border-secondary)] shadow-sm focus:border-[var(--border-focus)] focus:ring-[var(--ring-focus)] focus:ring-opacity-50 bg-[var(--bg-input)] text-[var(--text-primary)]"+ placeholder="Enter your new password">+ <p class="text-xs text-[var(--text-muted)] mt-1">Password must be at least 8 characters long.</p>+ </div>++ <div class="mb-6">+ <label for="confirm_password" class="block text-sm font-medium text-[var(--text-secondary)] mb-1">Confirm Password</label>+ <input type="password" id="confirm_password" name="confirm_password" required+ class="mt-1 block w-full rounded-md border-[var(--border-secondary)] shadow-sm focus:border-[var(--border-focus)] focus:ring-[var(--ring-focus)] focus:ring-opacity-50 bg-[var(--bg-input)] text-[var(--text-primary)]"+ placeholder="Confirm your new password">+ </div>++ <div class="flex flex-col space-y-4">+ <button type="submit" class="w-full py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-[var(--text-button)] bg-[var(--bg-button)] hover:bg-[var(--bg-button-hover)] focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[var(--border-focus)]">+ <i class="fas fa-key mr-2"></i> Reset Password+ </button>++ <div class="text-center text-sm text-[var(--text-muted)]">+ <a href="{{ url_for('auth.login') }}" class="font-medium text-[var(--text-accent)] hover:underline">+ <i class="fas fa-arrow-left mr-1"></i> Back to Login+ </a>+ </div>+ </div>+ </form>+ </div>+ </main>++ <footer class="text-center py-4 mt-8 text-xs text-[var(--text-light)] border-t border-[var(--border-primary)]">+ Speakr © {{ now.year }}+ </footer>+ </div>++ <script>+ document.addEventListener('DOMContentLoaded', function() {+ if (window.AppLoader) {+ AppLoader.waitForReady();+ }+ });+ </script>+</body>+</html>diff --git a/templates/auth/verify_success.html b/templates/auth/verify_success.htmlnew file mode 100644index 00000000..075cfd84--- /dev/null+++ b/templates/auth/verify_success.html@@ -0,0 +1,85 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <meta name="robots" content="noindex, nofollow, noarchive, nosnippet, noimageindex">+ <title>{{ title }} - Speakr</title>+ <link rel="icon" href="{{ url_for('static', filename='img/favicon.ico') }}" type="image/svg+xml">+ <script src="{{ url_for('static', filename='vendor/js/tailwind.min.js') }}"></script>+ <link rel="stylesheet" href="{{ url_for('static', filename='vendor/css/fontawesome.min.css') }}">+ <link rel="stylesheet" href="{{ url_for('static', filename='css/styles.css') }}">++ {% include 'includes/loading_overlay.html' %}++ <script>+ function applyTheme() {+ if (!document.documentElement) return;+ const savedMode = localStorage.getItem('darkMode');+ const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;+ if (savedMode === 'true' || (savedMode === null && prefersDark)) {+ document.documentElement.classList.add('dark');+ } else {+ document.documentElement.classList.remove('dark');+ }+ const savedScheme = localStorage.getItem('colorScheme') || 'blue';+ const isDark = document.documentElement.classList.contains('dark');+ const themePrefix = isDark ? 'theme-dark-' : 'theme-light-';+ const themeClasses = ['blue', 'emerald', 'purple', 'rose', 'amber', 'teal'];+ themeClasses.forEach(theme => {+ document.documentElement.classList.remove(`theme-light-${theme}`);+ document.documentElement.classList.remove(`theme-dark-${theme}`);+ });+ if (savedScheme !== 'blue') {+ document.documentElement.classList.add(themePrefix + savedScheme);+ }+ }+ applyTheme();+ </script>+</head>+<body class="bg-[var(--bg-primary)] text-[var(--text-primary)]">+ <div class="container mx-auto px-4 sm:px-6 lg:px-8 py-6 flex flex-col min-h-screen">+ <header class="flex justify-between items-center mb-6 pb-4 border-b border-[var(--border-primary)]">+ <h1 class="text-3xl font-bold text-[var(--text-primary)]">+ <a href="{{ url_for('recordings.index') }}" class="flex items-center">+ <img src="{{ url_for('static', filename='img/favicon.ico') }}" alt="Speakr Logo" class="h-9 w-9 mr-2">+ Speakr+ </a>+ </h1>+ </header>++ <main class="flex-grow flex items-center justify-center">+ <div class="w-full max-w-md bg-[var(--bg-secondary)] p-8 rounded-xl shadow-lg border border-[var(--border-primary)]">+ <div class="text-center">+ <div class="mb-6">+ <div class="w-20 h-20 mx-auto bg-[var(--bg-success-light)] rounded-full flex items-center justify-center">+ <i class="fas fa-check text-[var(--text-success-strong)] text-3xl"></i>+ </div>+ </div>++ <h2 class="text-2xl font-semibold text-[var(--text-primary)] mb-4">Email Verified!</h2>+ <p class="text-[var(--text-secondary)] mb-6">+ Your email address has been successfully verified. You can now log in to your account.+ </p>++ <a href="{{ url_for('auth.login') }}" class="inline-block w-full py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-[var(--text-button)] bg-[var(--bg-button)] hover:bg-[var(--bg-button-hover)] focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[var(--border-focus)] transition-colors duration-200">+ <i class="fas fa-sign-in-alt mr-2"></i> Continue to Login+ </a>+ </div>+ </div>+ </main>++ <footer class="text-center py-4 mt-8 text-xs text-[var(--text-light)] border-t border-[var(--border-primary)]">+ Speakr © {{ now.year }}+ </footer>+ </div>++ <script>+ document.addEventListener('DOMContentLoaded', function() {+ if (window.AppLoader) {+ AppLoader.waitForReady();+ }+ });+ </script>+</body>+</html>diff --git a/templates/login.html b/templates/login.htmlindex 69940a02..87cab134 100644--- a/templates/login.html+++ b/templates/login.html@@ -126,7 +126,7 @@{% endif %}</div>- <div class="mb-6">+ <div class="mb-4">{{ form.password.label(class="block text-sm font-medium text-[var(--text-secondary)] mb-1") }}{% if form.password.errors %}{{ form.password(class="mt-1 block w-full rounded-md border-[var(--border-danger)] shadow-sm focus:border-[var(--border-focus)] focus:ring-[var(--ring-focus)] focus:ring-opacity-50 bg-[var(--bg-input)] text-[var(--text-primary)]") }}@@ -140,9 +140,12 @@{% endif %}</div>- <div class="flex items-center mb-6">- {{ form.remember(class="h-4 w-4 text-[var(--text-accent)] focus:ring-[var(--ring-focus)] border-[var(--border-secondary)] rounded") }}- {{ form.remember.label(class="ml-2 block text-sm text-[var(--text-secondary)]") }}+ <div class="flex items-center justify-between mb-6">+ <div class="flex items-center">+ {{ form.remember(class="h-4 w-4 text-[var(--text-accent)] focus:ring-[var(--ring-focus)] border-[var(--border-secondary)] rounded") }}+ {{ form.remember.label(class="ml-2 block text-sm text-[var(--text-secondary)]") }}+ </div>+ <a href="{{ url_for('auth.forgot_password') }}" class="text-sm text-[var(--text-accent)] hover:underline">Forgot password?</a></div><div class="flex flex-col space-y-4">