Password reset working
This commit is contained in:
@@ -3,6 +3,7 @@ import { AccountTutorialStatus } from "@/interface/AccountTutorialStatus";
|
||||
import { RaidGroupPermissionType } from "@/interface/RaidGroup";
|
||||
import { api } from "@/util/AxiosUtil";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { AxiosError } from "axios";
|
||||
|
||||
|
||||
export function useGetAccounts(page: number, pageSize: number, searchTerm?: string){
|
||||
@@ -160,6 +161,28 @@ export function useUpdateTutorialsStatus(){
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdatePassword(){
|
||||
return useMutation({
|
||||
mutationKey: ["updatePassword"],
|
||||
mutationFn: async ({currentPassword, newPassword}:{currentPassword: string; newPassword: string;}) => {
|
||||
try{
|
||||
await api.post("/auth/resetPassword", {
|
||||
currentPassword,
|
||||
newPassword
|
||||
});
|
||||
}
|
||||
catch(error){
|
||||
if(error instanceof AxiosError && error.response?.data.errors){
|
||||
throw new Error(error.response?.data.errors.join(", "));
|
||||
}
|
||||
else{
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
export function useForcePasswordReset(accountId: string){
|
||||
|
||||
Reference in New Issue
Block a user