added function to change user password with the admin panel

This commit is contained in:
2025-09-03 14:10:42 +02:00
parent 423075e746
commit b8f13a37fd
5 changed files with 163 additions and 8 deletions

View File

@@ -73,6 +73,26 @@ export const createUser = async (
}
};
export const changePW = async (newPassword: string, username: string) => {
try {
const response = await fetch(`http://localhost:8002/api/changePWadmin`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${Cookies.get("token")}`,
},
body: JSON.stringify({ newPassword, username }),
});
if (!response.ok) {
throw new Error("Failed to change password");
}
return { success: true };
} catch (error) {
console.error("Error changing password:", error);
return { success: false };
}
};
export const deleteLoan = async (loanId: number) => {
try {
const response = await fetch(