feat(api): complete /auth contract (login/register/logout/refresh/me/profile)#69
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes the general JSON API auth contract (consumed by the Flutter app) for WordPress — the last backend in the cross-backend
/apisweep.What
WordPress owns its users, so auth is WP-native (rather than the host-callback model the plugin-style backends use):
login—wp_authenticate()verifies credentials, then issues an Escalated API token →{token, user}.register—wp_create_user()whenusers_can_registeris 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/registerare public; the rest require a Bearer token (reusingBase_Controller's token machinery).Verification
php -lclean;vendor/bin/pint --test(the lint CI gate) passes.Test_Api_Auth(live WP harness, runs in CI): login issues a token for valid creds, rejects bad creds (401) + missing creds (422),mereturns the user,logoutrevokes the token.