multiuser
This commit is contained in:
@@ -67,7 +67,7 @@ import { HomeCreateRoom } from './client/home/CreateRoom';
|
||||
import { Create } from './client/create';
|
||||
import { CreateSpaceModalRenderer } from '../features/create-space';
|
||||
import { SearchModalRenderer } from '../features/search';
|
||||
import { getFallbackSession } from '../state/sessions';
|
||||
import { getCurrentSession } from '../state/sessions';
|
||||
|
||||
export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize) => {
|
||||
const { hashRouter } = clientConfig;
|
||||
@@ -85,15 +85,37 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize)
|
||||
<Route
|
||||
index
|
||||
loader={() => {
|
||||
if (getFallbackSession()) return redirect(getHomePath());
|
||||
if (getCurrentSession()) return redirect(getHomePath());
|
||||
const afterLoginPath = getAppPathFromHref(getOriginBaseUrl(), window.location.href);
|
||||
if (afterLoginPath) setAfterLoginRedirectPath(afterLoginPath);
|
||||
return redirect(getLoginPath());
|
||||
}}
|
||||
/>
|
||||
<Route
|
||||
loader={() => {
|
||||
if (getFallbackSession()) {
|
||||
loader={({ request }) => {
|
||||
const url = new URL(request.url);
|
||||
const addingAccount = url.searchParams.get('add-account') === 'true';
|
||||
const hasSession = !!getCurrentSession();
|
||||
|
||||
// Log to localStorage for persistence across reloads
|
||||
const debugInfo = {
|
||||
timestamp: new Date().toISOString(),
|
||||
url: url.toString(),
|
||||
pathname: url.pathname,
|
||||
search: url.search,
|
||||
hash: url.hash,
|
||||
addingAccount,
|
||||
hasSession,
|
||||
willRedirect: hasSession && !addingAccount
|
||||
};
|
||||
console.log('[Router] Auth loader:', debugInfo);
|
||||
const debugLog = JSON.parse(localStorage.getItem('debug-router-logs') || '[]');
|
||||
debugLog.push(debugInfo);
|
||||
if (debugLog.length > 10) debugLog.shift(); // Keep last 10
|
||||
localStorage.setItem('debug-router-logs', JSON.stringify(debugLog));
|
||||
|
||||
if (hasSession && !addingAccount) {
|
||||
console.log('[Router] Redirecting to home because session exists and not adding account');
|
||||
return redirect(getHomePath());
|
||||
}
|
||||
|
||||
@@ -113,7 +135,7 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize)
|
||||
|
||||
<Route
|
||||
loader={() => {
|
||||
if (!getFallbackSession()) {
|
||||
if (!getCurrentSession()) {
|
||||
const afterLoginPath = getAppPathFromHref(
|
||||
getOriginBaseUrl(hashRouter),
|
||||
window.location.href
|
||||
|
||||
Reference in New Issue
Block a user