feat: Emails listing so admins can read saved emails without an email provider #17

Merged
ngqile merged 5 commits from add-admin-email-listing into main 2026-11-30 04:14:44 +00:00
Owner

OpenSpec change add-admin-email-listing.

Why

No email provider at go-live. Forgot-password and "Send password reset" still create emails with a temporary password, and service-email saves every email before sending it. An admin who can read the saved emails can pass the password on in person.

What

  • mobile-api GET /api/admin/emails lists saved emails newest first. It filters by recipient, subject and date range, pages with the size capped at 100, and never returns a body. GET /api/admin/emails/{id} returns one email with its body. Both sit under a new BO_EMAILS module.
  • A caller who is not a super admin cannot open an email addressed to a super admin (403 SUPER_ADMIN_REQUIRED).
  • Each view logs email <id> viewed by <user>, never the body.
  • Portal: /emails list and /emails/[id] detail. The body is shown only in <iframe sandbox="" srcDoc>.
  • Module row 40900000 BO_EMAILS, with no role grant: the local seed has it, and sql/01-email-module.sql is for the DBA.
  • docs/deployment.md: the later-SQL table, and the workaround with its exposure warning (section 10).

Exposure (deliberate, documented)

Emails shows every saved email, including other users' temporary passwords, member email-verification codes and form submissions with personal data. The module is ungranted by default, so grant it narrowly.

Verification

  • mobile-api verify: 507 tests green.
  • Portal: vitest 1190 passed, tsc clean, lint 0 errors, next build OK.
  • Live through the gateway:
    • list filters by recipient and date;
    • the detail returns the body, and the audit line has no body;
    • a non-super admin with BO_EMAILS gets 403 on an email to a super admin and 200 on an ordinary one;
    • a role without the module gets 403 on both endpoints.
  • Playwright on the local stack:
    • forgot-password from the login page, then filter the list, open the email and read the password in the isolated frame;
    • sign in with that password and get the forced change;
    • a non-super admin sees "Only a super admin can read this email." with no frame;
    • a user without the module sees no menu entry and "Not authorized";
    • 360px screenshots, with the subject column first so the link is reachable.
  • Per-task Review Gates and a whole-branch review passed. Review fixes are in 4b09008.

Follow-ups

  • service-email marks a failed send as Success (locally Mailjet answers Unauthorized, yet the status is Y).
  • The recipient filter's join can count an email twice in the total.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM

OpenSpec change `add-admin-email-listing`. ## Why No email provider at go-live. Forgot-password and "Send password reset" still create emails with a temporary password, and `service-email` saves every email before sending it. An admin who can read the saved emails can pass the password on in person. ## What - mobile-api `GET /api/admin/emails` lists saved emails newest first. It filters by recipient, subject and date range, pages with the size capped at 100, and never returns a body. `GET /api/admin/emails/{id}` returns one email with its body. Both sit under a new `BO_EMAILS` module. - A caller who is not a super admin cannot open an email addressed to a super admin (403 `SUPER_ADMIN_REQUIRED`). - Each view logs `email <id> viewed by <user>`, never the body. - Portal: `/emails` list and `/emails/[id]` detail. The body is shown only in `<iframe sandbox="" srcDoc>`. - Module row `40900000 BO_EMAILS`, with no role grant: the local seed has it, and `sql/01-email-module.sql` is for the DBA. - `docs/deployment.md`: the later-SQL table, and the workaround with its exposure warning (section 10). ## Exposure (deliberate, documented) Emails shows every saved email, including other users' temporary passwords, member email-verification codes and form submissions with personal data. The module is ungranted by default, so grant it narrowly. ## Verification - mobile-api `verify`: 507 tests green. - Portal: vitest 1190 passed, `tsc` clean, lint 0 errors, `next build` OK. - Live through the gateway: - list filters by recipient and date; - the detail returns the body, and the audit line has no body; - a non-super admin with `BO_EMAILS` gets 403 on an email to a super admin and 200 on an ordinary one; - a role without the module gets 403 on both endpoints. - Playwright on the local stack: - forgot-password from the login page, then filter the list, open the email and read the password in the isolated frame; - sign in with that password and get the forced change; - a non-super admin sees "Only a super admin can read this email." with no frame; - a user without the module sees no menu entry and "Not authorized"; - 360px screenshots, with the subject column first so the link is reachable. - Per-task Review Gates and a whole-branch review passed. Review fixes are in 4b09008. ## Follow-ups - service-email marks a failed send as Success (locally Mailjet answers Unauthorized, yet the status is `Y`). - The recipient filter's join can count an email twice in the total. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
ngqile added 5 commits 2026-11-30 04:14:41 +00:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
GET /api/admin/emails lists saved emails newest first (no bodies), and
GET /api/admin/emails/{id} returns one with its body, under a new BO_EMAILS
module. A caller who is not a super admin cannot open an email addressed to a
super admin. Each view logs the email id and viewer, never the body.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
List each email once when the recipient join returns it twice. The proposal,
design and handover now say Emails exposes every saved email, including member
verification codes and form submissions, not only password emails. The design
names the single catch-all proxy, the later-SQL table sits after the 04 check,
and the seed header says the release package is frozen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
ngqile merged commit 21bef0e4aa into main 2026-11-30 04:14:44 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ngqile/co-lite#17