next/server/api/auth/session.get.ts

12 lines
343 B
TypeScript
Raw Normal View History

export default eventHandler((event) => {
2023-12-29 20:11:07 -05:00
let ahead = (getHeaders(event).authorization || getCookie(event, "auth:token") || "")?.replace("Bearer ", "");
if (event.context.currentUser) {
return {
token: ahead,
user: event.context.currentUser,
};
} else {
throw createError({ statusCode: 400, message: "unauthenticated" });
}
});