fix(dashboards): prevent render loops with stable ready handlers and idempotent updates; improve filter hydration guards
fix(export): return 501 with hint when Playwright browsers missing; nicer error toast in UI fix(site-header): export primary/secondary buttons as named for SC safety; keep static props for compat fix(portal): add DialogDescription for a11y; tidy preview dialog fix(csats): avoid reinit state loops with timestamp guard chore(prisma): default dev DB to prisma/db.dev.sqlite and log path chore(auth): add dev bypass flags wiring (server/client) for local testing dev: seed script for Convex demo data
This commit is contained in:
parent
ff0254df18
commit
b62e14d8eb
13 changed files with 210 additions and 103 deletions
|
|
@ -90,7 +90,22 @@ export function useAuth() {
|
|||
export const { signIn, signOut, useSession } = authClient
|
||||
|
||||
export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
const { data: session, isPending } = useSession()
|
||||
const devBypass = process.env.NODE_ENV !== "production" && process.env.NEXT_PUBLIC_DEV_BYPASS_AUTH === "1"
|
||||
const { data: baseSession, isPending } = useSession()
|
||||
const session: AppSession | null = baseSession ?? (devBypass
|
||||
? {
|
||||
session: { id: "dev-session", expiresAt: Date.now() + 1000 * 60 * 60 },
|
||||
user: {
|
||||
id: "dev-user",
|
||||
name: "Dev Admin",
|
||||
email: "admin@sistema.dev",
|
||||
role: "admin",
|
||||
tenantId: "tenant-atlas",
|
||||
avatarUrl: null,
|
||||
machinePersona: null,
|
||||
},
|
||||
}
|
||||
: null)
|
||||
const ensureUser = useMutation(api.users.ensureUser)
|
||||
const [convexUserId, setConvexUserId] = useState<string | null>(null)
|
||||
const [machineContext, setMachineContext] = useState<MachineContext | null>(null)
|
||||
|
|
|
|||
|
|
@ -55,6 +55,24 @@ async function buildRequest() {
|
|||
|
||||
export async function getServerSession(): Promise<ServerSession | null> {
|
||||
try {
|
||||
// Dev-only bypass to simplify local dashboard access when auth is misconfigured.
|
||||
if (process.env.NODE_ENV !== "production" && process.env.DEV_BYPASS_AUTH === "1") {
|
||||
return {
|
||||
session: {
|
||||
id: "dev-session",
|
||||
expiresAt: Date.now() + 1000 * 60 * 60,
|
||||
},
|
||||
user: {
|
||||
id: "dev-user",
|
||||
name: "Dev Admin",
|
||||
email: "admin@sistema.dev",
|
||||
role: "admin",
|
||||
tenantId: "tenant-atlas",
|
||||
avatarUrl: null,
|
||||
machinePersona: null,
|
||||
},
|
||||
}
|
||||
}
|
||||
const request = await buildRequest()
|
||||
const session = await auth.api.getSession({
|
||||
headers: request.headers,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ export const auth = betterAuth({
|
|||
provider: "sqlite",
|
||||
}),
|
||||
user: {
|
||||
modelName: "authUser",
|
||||
// Prisma model name (case-sensitive)
|
||||
modelName: "AuthUser",
|
||||
additionalFields: {
|
||||
role: {
|
||||
type: "string",
|
||||
|
|
@ -47,17 +48,17 @@ export const auth = betterAuth({
|
|||
},
|
||||
},
|
||||
session: {
|
||||
modelName: "authSession",
|
||||
modelName: "AuthSession",
|
||||
cookieCache: {
|
||||
enabled: true,
|
||||
maxAge: 60 * 5,
|
||||
},
|
||||
},
|
||||
account: {
|
||||
modelName: "authAccount",
|
||||
modelName: "AuthAccount",
|
||||
},
|
||||
verification: {
|
||||
modelName: "authVerification",
|
||||
modelName: "AuthVerification",
|
||||
},
|
||||
emailAndPassword: {
|
||||
enabled: true,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ const resolvedDatabaseUrl = (() => {
|
|||
if (process.env.NODE_ENV === "production") {
|
||||
return "file:/app/data/db.sqlite"
|
||||
}
|
||||
return resolveFileUrl("file:./prisma/db.sqlite")
|
||||
// In development, prefer a dedicated dev DB file
|
||||
return resolveFileUrl("file:./prisma/db.dev.sqlite")
|
||||
})()
|
||||
|
||||
export const prisma =
|
||||
|
|
@ -51,3 +52,9 @@ export const prisma =
|
|||
if (process.env.NODE_ENV !== "production") {
|
||||
global.prisma = prisma
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
// Helps detect mismatched DB path during dev server bootstrap
|
||||
// eslint-disable-next-line no-console
|
||||
console.log("[prisma] Using database:", resolvedDatabaseUrl)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue