From c1acc3122d87bbb9a4f9ba22862528bdfc56386f Mon Sep 17 00:00:00 2001 From: Jens Luedicke Date: Sun, 6 Jul 2025 18:16:00 +0200 Subject: [PATCH] Disable initial email verification. --- app.py | 27 ++++----- models.py | 2 +- static/css/style.css | 90 ++++++++++++++++++++++++++++++ templates/layout.html | 47 ++++++++++++++++ templates/profile.html | 29 ++++++++-- templates/register.html | 8 +-- templates/register_freelancer.html | 5 +- 7 files changed, 183 insertions(+), 25 deletions(-) diff --git a/app.py b/app.py index dde955d..cbb5013 100644 --- a/app.py +++ b/app.py @@ -397,13 +397,18 @@ def load_logged_in_user(): else: g.company = None - # Check if user is verified - if not g.user.is_verified and request.endpoint not in ['verify_email', 'static', 'logout', 'setup_company']: - # Allow unverified users to access only verification and static resources - if request.endpoint not in ['login', 'register']: - flash('Please verify your email address before accessing this page.', 'warning') - session.clear() - return redirect(url_for('login')) + # Check if user has email but not verified + if g.user and not g.user.is_verified and g.user.email: + # Add a flag for templates to show email verification nag + g.show_email_verification_nag = True + else: + g.show_email_verification_nag = False + + # Check if user has no email at all + if g.user and not g.user.email: + g.show_email_nag = True + else: + g.show_email_nag = False else: g.company = None @@ -569,8 +574,6 @@ def register(): error = None if not username: error = 'Username is required' - elif not email: - error = 'Email is required' elif not password: error = 'Password is required' elif password != confirm_password: @@ -596,7 +599,7 @@ def register(): if company and not error: if User.query.filter_by(username=username, company_id=company.id).first(): error = 'Username already exists in this company' - elif User.query.filter_by(email=email, company_id=company.id).first(): + elif email and User.query.filter_by(email=email, company_id=company.id).first(): error = 'Email already registered in this company' if error is None and company: @@ -690,8 +693,6 @@ def register_freelancer(): error = None if not username: error = 'Username is required' - elif not email: - error = 'Email is required' elif not password: error = 'Password is required' elif password != confirm_password: @@ -708,7 +709,7 @@ def register_freelancer(): if not error: if User.query.filter_by(username=username).first(): error = 'Username already exists' - elif User.query.filter_by(email=email).first(): + elif email and User.query.filter_by(email=email).first(): error = 'Email already registered' if error is None: diff --git a/models.py b/models.py index 573ac1e..68de2e6 100644 --- a/models.py +++ b/models.py @@ -129,7 +129,7 @@ class Project(db.Model): class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), nullable=False) - email = db.Column(db.String(120), nullable=False) + email = db.Column(db.String(120), nullable=True) password_hash = db.Column(db.String(128)) created_at = db.Column(db.DateTime, default=datetime.utcnow) diff --git a/static/css/style.css b/static/css/style.css index d71b4e9..7c9b0aa 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -608,6 +608,96 @@ footer { margin: 0 0.5rem; } +/* Email Nag Banner */ +.email-nag-banner { + background-color: #e3f2fd; + border-bottom: 2px solid #1976d2; + padding: 0.75rem 1rem; + position: relative; + animation: slideDown 0.3s ease-out; +} + +.email-nag-banner.email-verify { + background-color: #fff3cd; + border-color: #ffc107; +} + +.email-nag-content { + max-width: 1200px; + margin: 0 auto; + display: flex; + align-items: center; + gap: 1rem; + flex-wrap: wrap; +} + +.email-nag-icon { + font-size: 1.5rem; + flex-shrink: 0; +} + +.email-nag-text { + flex: 1; + color: #333; + font-size: 0.95rem; +} + +.email-nag-dismiss { + position: absolute; + top: 0.5rem; + right: 1rem; + background: none; + border: none; + font-size: 1.5rem; + color: #666; + cursor: pointer; + padding: 0; + width: 30px; + height: 30px; + display: flex; + align-items: center; + justify-content: center; + border-radius: 4px; + transition: all 0.2s; +} + +.email-nag-dismiss:hover { + background-color: rgba(0,0,0,0.1); + color: #333; +} + +@keyframes slideDown { + from { + transform: translateY(-100%); + opacity: 0; + } + to { + transform: translateY(0); + opacity: 1; + } +} + +@keyframes slideUp { + from { + transform: translateY(0); + opacity: 1; + } + to { + transform: translateY(-100%); + opacity: 0; + } +} + +@media (max-width: 768px) { + .email-nag-content { + padding-right: 2rem; + } + + .email-nag-text { + font-size: 0.875rem; + } +} + /* Full width footer when no user (no sidebar) */ body:not(.has-user) footer { margin-left: 0; diff --git a/templates/layout.html b/templates/layout.html index 7830312..54da97b 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -206,6 +206,31 @@ {% endif %} {% endwith %} + + {% if g.show_email_nag %} +
+ +
+ {% elif g.show_email_verification_nag %} +
+ +
+ {% endif %} + {% block content %}{% endblock %} @@ -229,6 +254,28 @@ {% if g.user %} + {% else %} {% endif %} diff --git a/templates/profile.html b/templates/profile.html index 6333f16..b369610 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -93,7 +93,16 @@
Email - {{ user.email }} + + {% if user.email %} + {{ user.email }} + {% if not user.is_verified %} + Unverified + {% endif %} + {% else %} + Not provided + {% endif %} +
Role @@ -120,10 +129,20 @@
- - This email address is used for account verification and notifications. + + This email address is used for account recovery and notifications.
- + {% if user.email and not user.is_verified %} +
+ âš ī¸ Your email address is not verified. + Send Verification Email +
+ {% elif not user.email %} +
+ â„šī¸ Adding an email address enables account recovery and important notifications. +
+ {% endif %} +
@@ -132,7 +151,7 @@

Change Password

- +
diff --git a/templates/register.html b/templates/register.html index 745278f..4e42baf 100644 --- a/templates/register.html +++ b/templates/register.html @@ -47,9 +47,9 @@
📧 - - - We'll send a verification link to this address + + + Recommended for account recovery and notifications
@@ -80,7 +80,7 @@
-

📨 After registration, you'll need to verify your email address before you can log in.

+

💡 You can register without an email, but we recommend adding one later for account recovery.

diff --git a/templates/register_freelancer.html b/templates/register_freelancer.html index 7aa1719..7e7abb7 100644 --- a/templates/register_freelancer.html +++ b/templates/register_freelancer.html @@ -47,8 +47,9 @@
📧 - - + + + Recommended for account recovery