fix: send signed-out visitors on a shared chat link to the login page

Opening a shared chat link while signed out landed on the home page with a blank screen. Only a manual refresh reached the login page, and after signing in the visitor ended up on the home page, so the link had to be opened again. This happened with every sign-in method, OAuth included.

When the share could not be loaded, the share page navigated home twice. The second navigation cancelled the login redirect the first one had started, and since the app shell was already on screen, nothing checked the session again.

The share page now navigates once. Signed-out visitors go to the login page with the share as the redirect target, so they land on the shared chat after signing in, OAuth included, since the login page keeps the target across the provider round trip. Signed-in users on a dead or forbidden link still go home, and open shares still render without signing in.

Fixes #31334
This commit is contained in:
Classic298 2026-09-24 19:28:23 +02:00
parent 7ad0ae4687
commit 8f391131c5

View file

@ -52,8 +52,10 @@
if (await loadSharedChat()) {
await tick();
loaded = true;
} else {
} else if (localStorage.token) {
await goto('/');
} else {
await goto(`/auth?redirect=${encodeURIComponent($page.url.pathname)}`);
}
})();
}
@ -102,10 +104,7 @@
: []
);
await chatId.set(shareId);
chat = await getChatByShareId(token, shareId).catch(async (error) => {
await goto('/');
return null;
});
chat = await getChatByShareId(token, shareId).catch(() => null);
if (chat) {
user = token