Update various configuration files, components, and assets; enhance notification system and API endpoints; improve documentation and styles across the application.
This commit is contained in:
34
server/api/auth/validate.get.js
Normal file
34
server/api/auth/validate.get.js
Normal file
@@ -0,0 +1,34 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
const { userID } = event.context.user;
|
||||
|
||||
if (userID == null) {
|
||||
return {
|
||||
statusCode: 401,
|
||||
message: "Unauthorized",
|
||||
};
|
||||
}
|
||||
|
||||
const validatedUser = await prisma.user.findFirst({
|
||||
where: {
|
||||
userID: parseInt(userID),
|
||||
},
|
||||
});
|
||||
if (!validatedUser) {
|
||||
return {
|
||||
statusCode: 401,
|
||||
message: "Unauthorized",
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
message: "Authorized",
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
statusCode: 401,
|
||||
message: "Unauthorized",
|
||||
};
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user