feat: change password frontend added

This commit is contained in:
Timothy J. Baek 2023-12-29 00:26:47 -08:00
parent 9bd48ffd93
commit d8bb19fd8a
4 changed files with 69 additions and 5 deletions

View file

@ -88,3 +88,34 @@ export const userSignUp = async (name: string, email: string, password: string)
return res;
};
export const updateUserPassword = async (token: string, password: string, newPassword: string) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/auths/update/password`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
...(token && { authorization: `Bearer ${token}` })
},
body: JSON.stringify({
password: password,
new_password: newPassword
})
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.log(err);
error = err.detail;
return null;
});
if (error) {
throw error;
}
return res;
};