Rename Postgres tables for better recognition and add additional routes in web app

This commit is contained in:
Thilo Hohlt
2024-07-31 10:29:46 +02:00
parent a7f2fdebf5
commit d21e00a0c3
13 changed files with 601 additions and 243 deletions

View File

@@ -0,0 +1,36 @@
export const load = async ({ locals }) => {
return {
user: locals.user
};
};
export const actions = {
logout: async ({ cookies }) => {
cookies.delete("session_token", { path: "/" });
return { logout: { success: true } };
},
deleteAccount: async ({ request, fetch, cookies }) => {
const data = await request.formData();
const res = await fetch("http://localhost:3000/rpc/delete_account", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${cookies.get("session_token")}`
},
body: JSON.stringify({
password: data.get("password")
})
});
const response = await res.json();
if (!res.ok) {
return { deleteAccount: { success: false, message: response.message } };
}
cookies.delete("session_token", { path: "/" });
return { deleteAccount: { success: true } };
}
};