move conditional next-auth code to alternate files

This commit is contained in:
veganbeef
2025-07-23 18:54:08 -07:00
parent d0f8c75a2e
commit 8c5b8d8329
8 changed files with 338 additions and 141 deletions

View File

@@ -14,25 +14,10 @@ export default async function RootLayout({
}: Readonly<{
children: React.ReactNode;
}>) {
// Only get session if sponsored signer is enabled or seed phrase is provided
const sponsorSigner = process.env.SPONSOR_SIGNER === 'true';
const hasSeedPhrase = !!process.env.SEED_PHRASE;
const shouldUseSession = sponsorSigner || hasSeedPhrase;
let session = null;
if (shouldUseSession) {
try {
const { getSession } = await import('~/auth');
session = await getSession();
} catch (error) {
console.warn('Failed to get session:', error);
}
}
return (
<html lang="en">
<body>
<Providers session={session} shouldUseSession={shouldUseSession}>
<Providers>
{children}
</Providers>
</body>