12 lines
343 B
TypeScript
12 lines
343 B
TypeScript
export default eventHandler((event) => {
|
|
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" });
|
|
}
|
|
});
|