From 91f81027e4220dec0b6ba8f55e887b06c475c393 Mon Sep 17 00:00:00 2001 From: Edouard Vanbelle Date: Wed, 3 Jun 2026 11:23:17 +0200 Subject: [PATCH] fix(front:auth): fix issue with username that can now be empty --- static/js/app/authSession.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/static/js/app/authSession.js b/static/js/app/authSession.js index 4d3ab246..41b992bd 100644 --- a/static/js/app/authSession.js +++ b/static/js/app/authSession.js @@ -102,7 +102,10 @@ async function checkAuthentication() { // first load — `is_external` defaulting to falsy is correct // for the internal-user-by-default contract. app.isExternalUser = !!userData.is_external; - if (userData.username) { + // Gate on `id` — `username` is optional since PR 16 (users can + // sign in with no claimed handle, e.g. magic-link recipients). + // The UUID is the canonical signal that we have a populated DTO. + if (userData.id) { // We have cached user data — render immediately, refresh in background updateUserMenuData(); @@ -147,7 +150,12 @@ async function checkAuthentication() { console.log('No cached user data, fetching from server'); try { const freshData = await refreshUserData(); - if (freshData?.username) { + // See the cached-branch comment above: gate on `id`, not + // `username`. A magic-link recipient who hasn't claimed + // a handle yet returns a valid DTO with `username` + // omitted, and treating that as "couldn't retrieve + // user data" produced an infinite login → home loop. + if (freshData?.id) { updateUserMenuData(); updateStorageUsageDisplay(freshData); await resolveHomeFolder();