Skip to content

feat(api): complete /auth contract (login/register/logout/refresh/me/profile)#69

Merged
mpge merged 1 commit into
mainfrom
feat/api-auth
Jun 27, 2026
Merged

feat(api): complete /auth contract (login/register/logout/refresh/me/profile)#69
mpge merged 1 commit into
mainfrom
feat/api-auth

Conversation

@mpge

@mpge mpge commented Jun 27, 2026

Copy link
Copy Markdown
Member

Completes the general JSON API auth contract (consumed by the Flutter app) for WordPress — the last backend in the cross-backend /api sweep.

What

WordPress owns its users, so auth is WP-native (rather than the host-callback model the plugin-style backends use):

  • loginwp_authenticate() verifies credentials, then issues an Escalated API token → {token, user}.
  • registerwp_create_user() when users_can_register is on (else 403), then issues a token.
  • me / profile — read / wp_update_user() the token's user.
  • logout / refresh — revoke (and re-issue) the request's Bearer token.
  • validate — unchanged.

login/register are public; the rest require a Bearer token (reusing Base_Controller's token machinery).

Verification

  • php -l clean; vendor/bin/pint --test (the lint CI gate) passes.
  • New Test_Api_Auth (live WP harness, runs in CI): login issues a token for valid creds, rejects bad creds (401) + missing creds (422), me returns the user, logout revokes the token.

…profile)

Extend the API auth controller from the single validate endpoint to the full
Flutter contract. WordPress owns its users, so auth is WP-native: login
verifies credentials with wp_authenticate() and issues an Escalated API
token; register uses wp_create_user() when registration is open; me/profile
read/update the token's user; logout/refresh revoke (and re-issue) the
token. login/register are public; the rest require a Bearer token.
@mpge mpge merged commit 547d2f7 into main Jun 27, 2026
3 checks passed
@mpge mpge deleted the feat/api-auth branch June 27, 2026 10:47
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