auth code changes / misc
This commit is contained in:
@@ -3,10 +3,11 @@ import Base from "@/layouts/Base.astro";
|
||||
import Root from "@/components/AppLayout.jsx";
|
||||
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');
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ 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');
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,11 @@ import { requireAuthHook } from "@/hooks/requireAuthHook";
|
||||
|
||||
const user = await requireAuthHook(Astro);
|
||||
|
||||
if (!user) {
|
||||
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');
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
<Base>
|
||||
|
||||
Reference in New Issue
Block a user