Update createDatabase scripts & get sendUserInfo endpoint & when

creating an account it will also create a array in user_other_data.
This commit is contained in:
yuanhau 2025-06-07 09:21:37 +08:00
parent a4a522974a
commit 3a85eda19a
5 changed files with 84 additions and 33 deletions

View file

@ -0,0 +1,20 @@
import sql from "~/server/components/postgres";
export default defineEventHandler(async (event) => {
const body = await readBody(event);
const { request_change } = body;
const userToken = getCookie(event, "token");
if (!userToken) {
return {
error: "ERR_NOT_ALLOWED",
};
}
const checkUserToken = await sql`
select * from usertokens
where token=${userToken}
`;
if (checkUserToken.length === 0) {
return {
error: "ERR_NOT_ALLOWED",
};
}
});