mirror of
https://github.com/thiloho/archtika.git
synced 2025-11-22 19:01:35 +01:00
Rename Postgres tables for better recognition and add additional routes in web app
This commit is contained in:
36
web-app/src/routes/(authenticated)/account/+page.server.ts
Normal file
36
web-app/src/routes/(authenticated)/account/+page.server.ts
Normal 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 } };
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user