Skip to content

feat(showcase): accounts app — register/login/JWT/me (Phase 4)#526

Merged
ujeenet merged 1 commit into
developfrom
feat/e2e-showcase-phase4-accounts
May 23, 2026
Merged

feat(showcase): accounts app — register/login/JWT/me (Phase 4)#526
ujeenet merged 1 commit into
developfrom
feat/e2e-showcase-phase4-accounts

Conversation

@ujeenet
Copy link
Copy Markdown
Owner

@ujeenet ujeenet commented May 23, 2026

Summary

Phase 4 of the E2E showcase plan. Adds the `accounts` sub-app exercising the framework's auth primitives:

  • `rustango::passwords::{hash, verify}` round-trip via register + login
  • `rustango::jwt::{encode, decode}` round-trip via login → /me handshake
  • Bearer-token header parsing on the protected route
  • `unique` constraint on both username + email
  • 8-char minimum password validation
  • `auto_now_add` timestamp via the same re-fetch pattern blog/shop use

Routes

Method Path Auth Result
POST `/accounts/register` none 201 user
POST `/accounts/login` none 200 {token, user} or 401
GET `/accounts/me` Bearer 200 user or 401

Error coverage:

  • 400 on short password
  • 401 on bad credentials, unknown user, missing header, malformed header, tampered token
  • 409 on duplicate username/email

Playwright

10 new tests under `e2e/tests/accounts/`. Suite is now 23/23 passing locally (2 smoke + 5 blog + 6 shop + 10 accounts).

`SHOWCASE_JWT_SECRET` env wired through the playwright config so test runs are deterministic. Adds `@types/node` so the config's `process.env` reads typecheck cleanly.

CI matrix

Same shape as phases 2-3 — 23 tests against postgres / mysql / sqlite per matrix row.

Adds auth-flow coverage. Exercises:

- rustango::passwords::{hash, verify} round-trip via register + login
- rustango::jwt::{encode, decode} round-trip via login → /me handshake
- Bearer-token header parsing on the protected route
- unique constraint on both username and email
- 8-char minimum password validation
- auto_now_add timestamp on user creation (via existing
  re-fetch-after-insert pattern from blog/shop)

## Routes

POST /accounts/register   {username, email, password} → 201 user
POST /accounts/login      {username, password}        → 200 {token, user}
GET  /accounts/me         Bearer <token>              → 200 user

Error shapes:
- 400 on short password
- 401 on bad credentials, unknown user, missing header, malformed
  header, tampered token
- 409 on duplicate username/email

## JWT secret

SHOWCASE_JWT_SECRET env var; playwright config sets it for
deterministic test runs. Falls back to a fixed dev secret string.

## Playwright

10 new tests under e2e/tests/accounts/. Suite is now 23/23 passing
locally (2 smoke + 5 blog + 6 shop + 10 accounts).

Adds @types/node to the e2e package so the playwright config's
`process.env` reads typecheck cleanly.
@ujeenet ujeenet merged commit 28b7ed0 into develop May 23, 2026
11 checks passed
@ujeenet ujeenet deleted the feat/e2e-showcase-phase4-accounts branch May 23, 2026 12:55
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.

1 participant