From 370bf9d5b03cbcc18110300846450d863760edfc Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 22 Sep 2026 14:42:39 +0800 Subject: [PATCH] fix(tinode): trim tenant code before login_type comparison Code review of the login_type fix (11276804) found tenantCode.toLowerCase() === 'default' doesn't trim, so a tenant code with stray leading/trailing whitespace would be misclassified as enterprise (login_type:0) instead of personal (login_type:1). tenant.code always comes from the resolve response, not raw user input, so this was a latent edge case rather than a reproduced bug -- hardened anyway since the fix is free, matching the .trim() already used on tenant code elsewhere in this codebase. Co-Authored-By: Claude Sonnet 5 --- web/src/lib/tinode/connection.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/lib/tinode/connection.ts b/web/src/lib/tinode/connection.ts index 5b076958..33870422 100644 --- a/web/src/lib/tinode/connection.ts +++ b/web/src/lib/tinode/connection.ts @@ -173,7 +173,7 @@ function installOutgoingPacketPatches(t: Tinode) { const parsed = JSON.parse(msg); if (parsed.login && parsed.login.scheme === 'basic') { const tenantCode = useSessionStore.getState().tenant?.code || 'default'; - parsed.login.login_type = tenantCode.toLowerCase() === 'default' ? 1 : 0; + parsed.login.login_type = tenantCode.trim().toLowerCase() === 'default' ? 1 : 0; msg = JSON.stringify(parsed); } } catch {