• Lead VietProDev's avatar
    feat(oidc): email-verified register flow + resend endpoint · 9ee96c4b
    Lead VietProDev authored
    Wire the OIDC /interaction/:uid/register handler end-to-end so a brand-
    new account is created in 'pending_verification' status, a single-use
    token is persisted (SHA-256 hashed) in email_verify_tokens, and a
    verify-pending screen is rendered instead of the previous 501 stub.
    Auto-login is intentionally skipped: the user must click the link in
    the verification email before sign-in is allowed.
    
    Highlights:
    - EmailVerificationService: mints tokens, persists hashes, queues mail
      via MailService; dev mode returns the raw verify URL so the flow
      is testable without a working SMTP transport.
    - New POST /:uid/resend-verification: re-issues a fresh token; the
      response is identical for known and unknown emails to avoid leaking
      account existence.
    - Default 'user' role is assigned inside the same transaction as
      User + UserAuth creation; missing role is non-fatal.
    - New view verify-pending.hbs with resend + back-to-sign-in actions.
    - register.hbs upgraded to a 2-column responsive grid covering all
      OIDC profile fields (name, phone, gender, address, DOB) plus a
      required terms_accepted checkbox.
    - 8 unit tests in tests/unit/services/emailVerification.service.test.ts
      (buildVerificationUrl, createToken hash, verifyToken outcomes,
      resendVerificationEmail guard) - all passing.
    - RUN.md gained section 6.5 'Email Verification Flow' with REST/OIDC
      step-by-step, dev mode fallback, curl examples, env vars and a
      manual test checklist.
    - PROGRESS.md updated to log Phase 3 re-apply + Phase 4 + Phase 5,
      pre-existing TS errors out of scope, and rollback cheatsheet.
    
    Phase 4b (fix pre-existing TS errors in
    src/controllers/api/v1/auth/{verify-email,resend-verification}.ts and
    src/server.ts) is documented but deliberately out of scope for this
    commit to keep the blast radius small.
    
    Refs: pending_verification, email_verified_at columns,
    email_verify_tokens table (migration 040)
    Co-authored-by: 's avatarCursor <cursoragent@cursor.com>
    9ee96c4b
Name
Last commit
Last update
..
future Loading commit data...
001-auth-schema.sql Loading commit data...
002-file-schema.sql Loading commit data...
003-notification-schema.sql Loading commit data...
004-consolidated-migrations.sql Loading commit data...
005-resident-and-facility-schema.sql Loading commit data...
006-add-user-id-to-residents.sql Loading commit data...
007-active-views.sql Loading commit data...
008-remove-resident-stays-unique-constraint.sql Loading commit data...
009-remove-resident-stays-no-overlap-constraint.sql Loading commit data...
010-add-nationality-job-to-residents.sql Loading commit data...
011-add-cccd-document-types.sql Loading commit data...
012-add-contracts-schema.sql Loading commit data...
013-remove-file-duplicate-constraint.sql Loading commit data...
014-audit-log-system.sql Loading commit data...
015-drop-duplicate-public-audit-tables.sql Loading commit data...
016-add-contract-types-table.sql Loading commit data...
017-optimize-user-sessions-indexes.sql Loading commit data...
018-disable-outbox-poller.sql Loading commit data...
019-add-maintenance-incidents-schema.sql Loading commit data...
020-add-incident-code-and-deadline.sql Loading commit data...
021-alter-resident-documents-add-status.sql Loading commit data...
022-alter-technicians-link-user.sql Loading commit data...
023-add-posts-and-post_targets.sql Loading commit data...
024-add-apartment-to-posts-target_type.sql Loading commit data...
025-add-unique-constraint-beds-code.sql Loading commit data...
026-add-bills-schema.sql Loading commit data...
027-alter-bills-billing-period-type.sql Loading commit data...
028-add-soft-delete-to-bills.sql Loading commit data...
029-add-webhook-logs.sql Loading commit data...
030-recreate-webhook-logs-with-enum.sql Loading commit data...
031-add-thumbnail-id-to-posts.sql Loading commit data...
032-add-notification-templates.sql Loading commit data...
033-add-system-configs.sql Loading commit data...
034-add-debt-reminder-policies.sql Loading commit data...
035-add-oidc-schema.sql Loading commit data...
036-add-clients-schema.sql Loading commit data...
040-add-email-verified-at-and-address.sql Loading commit data...