feat(api): add isLoggedIn
utility function
for api routes which require authentication
This commit is contained in:
parent
1dcb1ae3f9
commit
2b0d478ca7
9
lib/server/middlewareButNotReally/isLoggedIn.ts
Normal file
9
lib/server/middlewareButNotReally/isLoggedIn.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { H3Event, EventHandlerRequest } from "h3";
|
||||
export default function (ev: H3Event<EventHandlerRequest>) {
|
||||
if (!ev.context.currentUser) {
|
||||
throw createError({
|
||||
statusCode: 401,
|
||||
statusMessage: "Authentication required",
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user