feat(api): complete /api/v1/auth contract via host callbacks#104
Merged
Conversation
Extend the API auth controller from validate to the full Flutter contract: login, register, logout, refresh, me, profile. Credential handling is delegated to host-app callbacks (config.apiAuth.*) — Escalated owns no passwords or sessions. The new endpoints live in a public route group (no API-token middleware) since they carry no token yet; an unconfigured callback responds 501, a null result is an auth failure (401).
The controller unit spec imported the controller, whose runtime '../../helpers/config.js' import cannot be resolved by CI's native 'node --test tests/unit/*.spec.ts' leg (no tsx deep .js->.ts resolution). Extract the callback delegation + bearer parsing into a pure src/helpers/api_auth.ts (no runtime imports) that the controller reuses, and unit-test that helper directly. Same 501/401/200 host-callback contract, now runnable under the native test runner.
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
/api/v1auth contract for Adonis — the last backend in the cross-backend sweep.What
config.apiAuthhost callbacks (authenticate/register/validate/refresh/updateProfile/logout) added toEscalatedConfig.ApiAuthControllergainslogin,register,logout,refresh,me,profile(joining the existingvalidate). Bearer token read from theAuthorizationheader. Unconfigured callback →501;nullresult →401.AuthenticateApiToken, since they carry no token yet);validatestays in the token-authed group.Verification
tsc --noEmitclean;eslint(the lint CI gate) clean (formatted with the locked prettier 3.8.5).tests/unit/api_auth_controller.spec.ts— 5 tests (501 not-configured, delegation, 401 null, me forwards bearer token, logout always-200).