mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-09 20:12:10 +10:00
feat(acls): added backend acls
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import { H3Error } from "h3";
|
||||
import sessionHandler from "../internal/session";
|
||||
|
||||
export default defineNitroPlugin((nitro) => {
|
||||
nitro.hooks.hook("error", async (error, { event }) => {
|
||||
@ -13,9 +14,8 @@ export default defineNitroPlugin((nitro) => {
|
||||
switch (error.statusCode) {
|
||||
case 401:
|
||||
case 403:
|
||||
const userId = await event.context.session.getUserId(event);
|
||||
const userId = await sessionHandler.getUserId(event);
|
||||
if (userId) break;
|
||||
console.log("user is signed out, redirecting");
|
||||
return sendRedirect(
|
||||
event,
|
||||
`/signin?redirect=${encodeURIComponent(event.path)}`
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
import session from "../internal/session";
|
||||
|
||||
export default defineNitroPlugin((nitro) => {
|
||||
nitro.hooks.hook('request', (h3) => {
|
||||
h3.context.session = session;
|
||||
})
|
||||
});
|
||||
Reference in New Issue
Block a user