added function to change user password with the admin panel
This commit is contained in:
@@ -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(
|
||||
|
Reference in New Issue
Block a user