Skip to content

fix(jwt): call dbappconnect alongside loadAppModels in resolveAuthContext#87

Merged
kennethphough merged 1 commit into
masterfrom
fix/jwt-login-app-db-setup
May 22, 2026
Merged

fix(jwt): call dbappconnect alongside loadAppModels in resolveAuthContext#87
kennethphough merged 1 commit into
masterfrom
fix/jwt-login-app-db-setup

Conversation

@kennethphough

Copy link
Copy Markdown
Member

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

…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>
@kennethphough
kennethphough merged commit 2775902 into master May 22, 2026
4 checks passed
@kennethphough
kennethphough deleted the fix/jwt-login-app-db-setup branch May 22, 2026 17:17
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