fix(portal): prevent /login redirect for client dev users when session.id is null
When a client clicks "Abigail Brooks" in the dev login selector, POST /api/portal/dev-session returns 201 but the session may not have id set immediately (timing issue or API response). This caused both CustomerPortal and Dashboard to redirect to /login because session?.id was null. Changes: - CustomerPortal: don't redirect to /login for client dev users even if session is null — the dev-session flow has verified the user - Dashboard: check for dev user before redirecting when sessionId is null This ensures client dev users see the portal rather than being immediately redirected back to /login. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import { Navigate } from "react-router-dom";
|
||||
import { Calendar, Clock, PawPrint, CreditCard, Star, ChevronRight, AlertTriangle } from "lucide-react";
|
||||
import { getDevUser } from "../pages/DevLoginSelector.js";
|
||||
|
||||
interface DashboardProps {
|
||||
sessionId: string | null;
|
||||
@@ -186,7 +187,11 @@ export function Dashboard({
|
||||
);
|
||||
}
|
||||
|
||||
if (!sessionId && !isImpersonating) {
|
||||
// Don't redirect to /login if we have a dev user — dev sessions may not have
|
||||
// sessionId set immediately after creation (session?.id may be null due to
|
||||
// timing or API response issues). Dev users are stored in localStorage and
|
||||
// verified via the dev-session flow, so they should see the portal.
|
||||
if (!sessionId && !isImpersonating && !getDevUser()) {
|
||||
return <Navigate to="/login" replace />;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user