mirror of
https://github.com/Drop-OSS/drop
synced 2026-08-27 14:23:05 -04:00
ca groundwork
This commit is contained in:
parent
94e8ad5c9a
commit
5e74a555df
44 changed files with 628 additions and 130 deletions
15
server/middleware/require-user.global.ts
Normal file
15
server/middleware/require-user.global.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
const whitelistedPrefixes = ["/signin", "/register"];
|
||||
|
||||
export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||
if (import.meta.server) return;
|
||||
if (whitelistedPrefixes.findIndex((e) => to.fullPath.startsWith(e)) != -1)
|
||||
return;
|
||||
|
||||
const user = useUser();
|
||||
if (user === undefined) {
|
||||
await updateUser();
|
||||
}
|
||||
if (!user.value) {
|
||||
return navigateTo({ path: "/signin", query: { redirect: to.fullPath } });
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue