Skip to content

PR-V2 — Backend: verify-email + resend-verification endpoints #64

Description

@martindolores

Why

PR-V1 adds the gate and token fields but nothing sends the email or lets a user complete verification. This wires it end-to-end using the IEmailService from PR-E1 (#18).

This chunk

  • POST /api/auth/verify-email { token } — look up by token, check expiry, set EmailConfirmed = true, clear token fields, then issue access+refresh tokens (auto-login after verifying, matching how AcceptInvitationAsync already behaves).
  • POST /api/auth/resend-verification { email } — regenerate token + expiry for an unconfirmed user; respond identically regardless of whether the email exists/is already confirmed (no enumeration).
  • RegisterOrganizationAsync now calls IEmailService.SendVerificationEmailAsync(...) after commit, not failing the request if sending fails — RegisterResponse gains an EmailSent flag, mirroring CreateInvitationAsync's response from PR-E1.
  • Inline HTML template (same style as the PR-E1 invitation template), linking to {Frontend:BaseUrl}/verify-email?token={token}.
  • Unit tests: success, expired token, unknown token, already-confirmed.

Builds on the data model from PR-V1 and the email-sending infrastructure from PR-E1 (#18).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions