Skip to content

Add email required validation and email verification flow#56

Merged
v0l merged 6 commits into
masterfrom
copilot/make-email-required-field
Feb 20, 2026
Merged

Add email required validation and email verification flow#56
v0l merged 6 commits into
masterfrom
copilot/make-email-required-field

Conversation

Copilot AI commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Email addresses were stored without format validation or ownership verification. This adds format enforcement, required-email gating for email notifications, and a full verification flow.

DB

  • Migration adds email_verified BIT(1) NOT NULL DEFAULT 0, email_verify_token VARCHAR(64) NOT NULL DEFAULT '', and modifies email to VARCHAR(255) NOT NULL DEFAULT '' on users
  • User.email changed from Option<EncryptedString> to EncryptedString (empty string = not set); email_verified: bool and email_verify_token: String added
  • New get_user_by_email_verify_token(token) DB method + trait entry

API

  • PATCH /api/v1/account:
    • Validates email format (@ + . check)
    • Email is required — attempting to clear/remove it returns an error
    • Returns error if contact_email: true with no email set
    • On email change: sets email_verified = false, generates 32-byte hex token, persists it, queues SendEmailVerification job
  • New GET /api/v1/account/verify-email?token=<token>: sets email_verified = true and clears the token; returns a styled HTML page (via verify-email.html mustache template) confirming success or showing an error message (no auth required — link is the credential)
  • GET /api/v1/account response now includes email_verified: bool (read-only; ignored on PATCH)

Worker

  • New WorkJob::SendEmailVerification { user_id, verify_url } handled by send_email_verification()
  • Shared send_email(smtp, to, subject, message) static helper used by both send_notification and send_email_verification, eliminating duplicated SMTP/template logic
  • email.html converted to mustache template ({{message}}, {{year}})
  • New verify-email.html mustache template ({{title}}, {{message}}, {{color}}) included via include_str!

Admin

  • AdminUserInfo now exposes email_verified for visibility in the admin panel
Original prompt

This section details on the original issue you should resolve

<issue_title>Make email requred</issue_title>
<issue_description>- [ ] Make the email address required field

  • Add email verification flow</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI assigned Copilot and v0l Feb 19, 2026
Copilot AI changed the title [WIP] Make email address a required field Add email required validation and email verification flow Feb 19, 2026
Copilot AI requested a review from v0l February 19, 2026 13:57
Comment thread lnvps_api/src/api/routes.rs Outdated
Comment thread lnvps_api/src/api/routes.rs
Comment thread lnvps_api/src/worker.rs Outdated
Comment thread lnvps_db/migrations/20260219000000_email_verification.sql Outdated
Comment thread lnvps_db/migrations/20260219000000_email_verification.sql Outdated
Comment thread lnvps_api/src/api/routes.rs Outdated
Comment thread lnvps_api/src/worker.rs Outdated
Comment thread lnvps_db/src/model.rs Outdated
@v0l
v0l marked this pull request as ready for review February 19, 2026 15:15
Copilot AI and others added 6 commits February 20, 2026 16:45
…ations

Co-authored-by: v0l <1172179+v0l@users.noreply.github.com>
Co-authored-by: v0l <1172179+v0l@users.noreply.github.com>
…d_email, BIT(1) migration

Co-authored-by: v0l <1172179+v0l@users.noreply.github.com>
…il required in User model

Co-authored-by: v0l <1172179+v0l@users.noreply.github.com>
…ror handling

- Rename migration to unique timestamp (20260220165223)
- Fix migration to handle NULL emails and drop unique index
- Use triple braces in mustache for unescaped HTML links
- Add link styling for dark background (#3498db)
- Use OpError for SMTP errors: Fatal (5xx) skipped, Transient retried
- Add docs/agents/migrations.md with timestamp rules
@v0l
v0l force-pushed the copilot/make-email-required-field branch from 3def3a1 to 2505af8 Compare February 20, 2026 17:15
@v0l
v0l merged commit f25a3ac into master Feb 20, 2026
0 of 2 checks passed
@v0l
v0l deleted the copilot/make-email-required-field branch February 20, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make email requred

2 participants