mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-24 05:24:23 +00:00
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:
parent
a4a522974a
commit
3a85eda19a
5 changed files with 84 additions and 33 deletions
20
server/api/user/sendUserInfo.post.ts
Normal file
20
server/api/user/sendUserInfo.post.ts
Normal 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",
|
||||
};
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue