Compare commits
2 Commits
03b1d761f0
...
02cd490700
Author | SHA1 | Date |
---|---|---|
Derrick Hammer | 02cd490700 | |
Derrick Hammer | 1dae0ba771 |
|
@ -1,4 +1,4 @@
|
|||
import type {AuthProvider} from "@refinedev/core"
|
||||
import type {AuthProvider, UpdatePasswordFormTypes} from "@refinedev/core"
|
||||
|
||||
import type {
|
||||
AuthActionResponse,
|
||||
|
@ -31,9 +31,8 @@ export type Identity = {
|
|||
email: string;
|
||||
}
|
||||
|
||||
export type UpdatePasswordFormRequest = {
|
||||
export interface UpdatePasswordFormRequest extends UpdatePasswordFormTypes{
|
||||
currentPassword: string;
|
||||
newPassword: string;
|
||||
}
|
||||
|
||||
export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => {
|
||||
|
@ -102,7 +101,7 @@ export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => {
|
|||
|
||||
async updatePassword(params: UpdatePasswordFormRequest): Promise<AuthActionResponse> {
|
||||
maybeSetupAuth();
|
||||
const ret = await sdk.account().updatePassword(params.currentPassword, params.newPassword);
|
||||
const ret = await sdk.account().updatePassword(params.currentPassword, params.password as string);
|
||||
|
||||
if (ret) {
|
||||
if (ret instanceof Error) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import { Input } from "~/components/ui/input";
|
|||
import { UsageCard } from "~/components/usage-card";
|
||||
|
||||
import QRImg from "~/images/QR.png";
|
||||
import {UpdatePasswordFormRequest} from "~/data/auth-provider.js";
|
||||
|
||||
export default function MyAccount() {
|
||||
const { data: identity } = useGetIdentity<{ email: string }>();
|
||||
|
@ -292,7 +293,7 @@ const ChangePasswordForm = ({
|
|||
open: boolean;
|
||||
setOpen: (value: boolean) => void;
|
||||
}) => {
|
||||
const { mutate: updatePassword } = useUpdatePassword<{ password: string }>();
|
||||
const { mutate: updatePassword } = useUpdatePassword<UpdatePasswordFormRequest>();
|
||||
const [form, fields] = useForm({
|
||||
id: "login",
|
||||
constraint: getZodConstraint(ChangePasswordSchema),
|
||||
|
@ -306,6 +307,7 @@ const ChangePasswordForm = ({
|
|||
const data = Object.fromEntries(new FormData(e.currentTarget).entries());
|
||||
|
||||
updatePassword({
|
||||
currentPassword: data.currentPassword.toString(),
|
||||
password: data.newPassword.toString(),
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue