mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 07:41:02 +08:00
Compare commits
No commits in common. "75b9bccdd160c8e1763a4261d557c755b50d6257" and "ad0f13a1a25a149963227bd632e4ff7c543ae5b3" have entirely different histories.
75b9bccdd1
...
ad0f13a1a2
@ -1,11 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
// FOR THIS MODULE DO NOT USE THE ?APPNAME URL TYPE, IT WILL FALL AT ALL TIMES, I HAVE NO CLUE WHY IS BEHAVIOR HAPPENING RN?
|
||||
import {
|
||||
SparklesIcon,
|
||||
UserIcon,
|
||||
NewspaperIcon,
|
||||
StarIcon,
|
||||
} from "lucide-vue-next";
|
||||
import { SparklesIcon, UserIcon, NewspaperIcon } from "lucide-vue-next";
|
||||
import translate from "translate";
|
||||
|
||||
interface translateInterfaceText {
|
||||
@ -183,7 +178,6 @@ const aiSummary = async () => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button><StarIcon /></button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -100,24 +100,23 @@ const checkValidApiKey = () => {
|
||||
const showDeleteDialog = ref(false);
|
||||
const showLogoutDialog = ref(false);
|
||||
const confirmDelete = async () => {
|
||||
showDeleteDialog.value = false;
|
||||
await deleteAccount();
|
||||
await validateUserInfo();
|
||||
showDeleteDialog.value = false;
|
||||
};
|
||||
|
||||
const deleteAccount = async () => {
|
||||
const req = await fetch("/api/user/sendUserChanges", {
|
||||
method: "DELETE",
|
||||
});
|
||||
const res = await req.json();
|
||||
const res = await res.json();
|
||||
console.log(res);
|
||||
};
|
||||
|
||||
const submitChangeAction = async (action: string) => {
|
||||
//const allowedColumns = ["firstname", "email"];
|
||||
const actions = [
|
||||
{ name: "NAME", SQLSystem: "firstname", sendValue: enterFirstName.value },
|
||||
{ name: "USER_EMAIL", SQLSystem: "email", sendValue: enteruseremail.value },
|
||||
{ name: "NAME", sendValue: enterFirstName.value },
|
||||
{ name: "USER_EMAIL", sendValue: enteruseremail.value },
|
||||
];
|
||||
|
||||
const actionMatch = actions.find((a) => a.name === action);
|
||||
@ -132,7 +131,7 @@ const submitChangeAction = async (action: string) => {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
action: actionMatch.SQLSystem,
|
||||
action: actionMatch.name,
|
||||
value: actionMatch.sendValue,
|
||||
jsonValue: "",
|
||||
}),
|
||||
@ -141,9 +140,7 @@ const submitChangeAction = async (action: string) => {
|
||||
const response = await req.json();
|
||||
if (response.error) {
|
||||
console.error("Error updating user data:", response.error);
|
||||
return;
|
||||
}
|
||||
await validateUserInfo();
|
||||
} catch (error) {
|
||||
console.error("Failed to submit change:", error);
|
||||
}
|
||||
|
@ -2,8 +2,5 @@
|
||||
const { t } = useI18n();
|
||||
</script>
|
||||
<template>
|
||||
<div class="justify-center align-center text-center">
|
||||
<h1 class="text-2xl text-bold">{{ t("pages.tos.title") }}</h1>
|
||||
<p>{{ t("pages.tos.content") }}</p>
|
||||
</div>
|
||||
<div></div>
|
||||
</template>
|
||||
|
@ -1,30 +0,0 @@
|
||||
import sql from "~/server/components/postgres";
|
||||
import getUserTokenMinusSQLInjection from "~/server/components/getUserToken";
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
const slug = getRouterParam(event, "slug");
|
||||
const token = await getUserTokenMinusSQLInjection(event);
|
||||
if (token.error.length !== 0) {
|
||||
return {
|
||||
error: token.error,
|
||||
};
|
||||
}
|
||||
const getOtherUserDataJsonFile = await sql`
|
||||
SELECT starred_news from user_other_data
|
||||
where username = ${token.user}
|
||||
`;
|
||||
if (getOtherUserDataJsonFile.length === 0) {
|
||||
return {
|
||||
error: "ERR_NO_DATA",
|
||||
};
|
||||
}
|
||||
const jsonData = getOtherUserDataJsonFile[0].starred_news;
|
||||
return jsonData;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return {
|
||||
error: "INTERNAL_SERVER_ERR",
|
||||
e: e.message,
|
||||
};
|
||||
}
|
||||
});
|
@ -1,30 +0,0 @@
|
||||
import sql from "~/server/components/postgres";
|
||||
import getUserTokenMinusSQLInjection from "~/server/components/getUserToken";
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
const slug = getRouterParam(event, "slug");
|
||||
const token = await getUserTokenMinusSQLInjection(event);
|
||||
if (token.error.length !== 0) {
|
||||
return {
|
||||
error: token.error,
|
||||
};
|
||||
}
|
||||
const getOtherUserDataJsonFile = await sql`
|
||||
SELECT starred_news from user_other_data
|
||||
where username = ${token.user}
|
||||
`;
|
||||
if (getOtherUserDataJsonFile.length === 0) {
|
||||
return {
|
||||
error: "ERR_NO_DATA",
|
||||
};
|
||||
}
|
||||
const jsonData = getOtherUserDataJsonFile[0].starred_news;
|
||||
return jsonData;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return {
|
||||
error: "INTERNAL_SERVER_ERR",
|
||||
e: e.message,
|
||||
};
|
||||
}
|
||||
});
|
@ -1,6 +1,7 @@
|
||||
/*// Fixed data for testing
|
||||
// Fixed data for testing
|
||||
export default defineEventHandler(async (event) => {
|
||||
return {
|
||||
langPref: "en",
|
||||
doNotShowLangPrefPopUp: false,
|
||||
email: "test@yuanhau.com",
|
||||
name: "Howard",
|
||||
@ -12,48 +13,3 @@ export default defineEventHandler(async (event) => {
|
||||
},
|
||||
};
|
||||
});
|
||||
*/
|
||||
import sql from "~/server/components/postgres";
|
||||
import getUserTokenMinusSQLInjection from "~/server/components/getUserToken";
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
const token = await getUserTokenMinusSQLInjection(event);
|
||||
if (token.error.length !== 0) {
|
||||
return {
|
||||
error: token.error,
|
||||
};
|
||||
}
|
||||
const fetchMainData = await sql`
|
||||
SELECT * FROM users
|
||||
WHERE username = ${token.user}
|
||||
`;
|
||||
const fetchOtherUserData = await sql`
|
||||
SELECT * FROM user_other_data
|
||||
WHERE username = ${token.user}
|
||||
`;
|
||||
|
||||
if (fetchMainData.length === 0 || fetchOtherUserData.length === 0) {
|
||||
return {
|
||||
error: "ERR_USER_DOESNT_EXIST",
|
||||
};
|
||||
}
|
||||
return {
|
||||
doNotShowLangPrefPopUp:
|
||||
fetchOtherUserData[0].remove_translate_popup || false,
|
||||
email: fetchMainData[0].email || "",
|
||||
name: fetchMainData[0].firstname || "",
|
||||
useCustomGroqKey: +(fetchOtherUserData[0].groq_api_key?.length ?? 0) > 0,
|
||||
translate: {
|
||||
enabled: fetchOtherUserData[0].translate_enabled || false,
|
||||
lang: "en",
|
||||
provider: fetchOtherUserData[0].translate_provider || "google",
|
||||
},
|
||||
};
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return {
|
||||
error: "ERR_SERVER_SIDE",
|
||||
e: e.message,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
@ -81,9 +81,6 @@ export default defineEventHandler(async (event) => {
|
||||
VALUES (${fetchUserInfoAgain[0].username}, ${newToken})
|
||||
`;
|
||||
|
||||
const getUserFirstName = await sql`
|
||||
select * from user_other_data`;
|
||||
|
||||
setCookie(event, "token", newToken);
|
||||
return {
|
||||
user: fetchUserInfoAgain,
|
||||
|
@ -12,34 +12,23 @@ export default defineEventHandler(async (event) => {
|
||||
const body = await readBody(event);
|
||||
if (body.jsonValue.length === 0) {
|
||||
const clearBadDataRegex = /[@-_.+a-zA-Z0-9]{2,}/;
|
||||
let allowed = true;
|
||||
if (body.value.match()) {
|
||||
allowed = false;
|
||||
}
|
||||
// Use Static values for now.
|
||||
const requestChange = body.action || "";
|
||||
const requestChange = "groq_api_key";
|
||||
const apiKeyqq = body.value.match(clearBadDataRegex);
|
||||
const allowedColumns = ["firstname", "email"];
|
||||
const allowedColumns = ["groq_api_key", "another_column_name"];
|
||||
|
||||
if (!allowedColumns.includes(requestChange)) {
|
||||
return {
|
||||
error: "ERR_NOT_ALLOWED",
|
||||
};
|
||||
} else if (requestChange === "firstname") {
|
||||
const sqlC = await sql`
|
||||
UPDATE users SET firstname = ${apiKeyqq[0]}
|
||||
WHERE username = ${token.user}`;
|
||||
return {
|
||||
sqlC: sqlC,
|
||||
success: true,
|
||||
};
|
||||
} else if (requestChange === "email") {
|
||||
const sqlC = await sql`
|
||||
UPDATE users SET email = ${apiKeyqq[0]}
|
||||
WHERE username = ${token.user}`;
|
||||
return {
|
||||
sqlC: sqlC,
|
||||
success: true,
|
||||
};
|
||||
throw new Error("Invalid column name provided");
|
||||
}
|
||||
|
||||
const sqlC = await sql.unsafe(
|
||||
`UPDATE user_other_data SET ${requestChange} = $1 WHERE username = $2`,
|
||||
`
|
||||
UPDATE user_other_data SET ${requestChange} = $1
|
||||
WHERE username = $2`,
|
||||
[apiKeyqq[0], token.user],
|
||||
);
|
||||
return {
|
||||
|
@ -43,7 +43,7 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
return {
|
||||
userAccount: fetchViaSQL[0].username,
|
||||
firstName: "",
|
||||
firstName: fetchViaSQL[0].firstName,
|
||||
requested_action: "CONTINUE",
|
||||
current_spot: "KEEP_LOGIN",
|
||||
email: fetchViaSQL[0].email,
|
||||
|
Loading…
x
Reference in New Issue
Block a user