login page / auth flow changes

This commit is contained in:
2025-11-26 10:08:24 -05:00
parent eb38f8865f
commit 21b112f460
8 changed files with 37 additions and 11 deletions

View File

@@ -6,8 +6,6 @@ import { requireAuthHook } from "@/hooks/requireAuthHook";
const user = await requireAuthHook(Astro);
if (!user) {
const decodedUrl = decodeURIComponent(Astro.url.pathname + Astro.url.search);
Astro.cookies.set('returnTo', decodedUrl, { path: '/' });
return Astro.redirect('/login');
}

View File

@@ -6,8 +6,6 @@ import { requireAuthHook } from "@/hooks/requireAuthHook";
const user = await requireAuthHook(Astro);
if (!user) {
const decodedUrl = decodeURIComponent(Astro.url.pathname + Astro.url.search);
Astro.cookies.set('returnTo', decodedUrl, { path: '/' });
return Astro.redirect('/login');
}

View File

@@ -6,8 +6,6 @@ import { requireAuthHook } from "@/hooks/requireAuthHook";
const user = await requireAuthHook(Astro);
if (!user || !user.roles.includes('lighting')) {
const decodedUrl = decodeURIComponent(Astro.url.pathname + Astro.url.search);
Astro.cookies.set('returnTo', decodedUrl, { path: '/' });
return Astro.redirect('/login');
}
---

View File

@@ -2,11 +2,15 @@
import LoginPage from '@/components/Login.jsx';
import Base from "@/layouts/Base.astro";
import Root from "@/components/AppLayout.jsx";
import { requireAuthHook } from '@/hooks/requireAuthHook';
const user = await requireAuthHook(Astro);
const isLoggedIn = Boolean(user);
---
<Base>
<section>
<div class="prose prose-neutral dark:prose-invert">
<Root child="LoginPage" client:only="react" >
<Root child="LoginPage" loggedIn={isLoggedIn} client:only="react" >
</Root>
</section>
</Base>