fix(jwt): call dbappconnect alongside loadAppModels in resolveAuthContext#87
Merged
Merged
Conversation
…text v4.4.3 unlocked the user_model constant via loadAppModels but left a second gap: the loaded model_definition has 'appId' set, so ModelObject->retrieve() auto-switches to the app DB via Api::dbswitch(true). But the app-DB credentials were never configured — Api::dbappconnect() is called only by the normal MVC pipeline (Api.php:690) and JWT bypasses that. Result: mysqli with null host/user/password → Unix socket attempt → "No such file or directory" → HTTP 500. Fix: call Api::dbappconnect($app->db_name, $app->db_username, $app->db_password) immediately after loadAppModels. The HMAC pipeline does these two calls back-to-back at Api.php:688-690 — JWT now matches. defineAppEnvironmentConstants / defineAppDataStore are deliberately NOT mirrored: they're private instance methods on Api (not statically reachable), and login is just user lookup + password_verify which doesn't need KYTE_APP_ENV / KYTE_APP_DATASTORE constants. All 12 JwtEndpointTest tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Fix continuation of v4.4.3. JWT login on apps with custom user_model was still 500ing because Api::dbappconnect was never called — the framework's HMAC pipeline calls it at Api.php:690 right after loadAppModels, but JWT bypasses that pipeline.
Fix: call dbappconnect in resolveAuthContext immediately after loadAppModels. Matches the HMAC sequence at Api.php:688-690.
Manually reproduced + verified on dev kyte-api.stratis-troika.com (mysqli 'No such file or directory' in php-fpm error log). All 12 JwtEndpointTest tests still pass.
Patch v4.4.4.
🤖 Generated with Claude Code