Compare commits

...

2 Commits

2 changed files with 7 additions and 6 deletions

View File

@ -1,4 +1,4 @@
import type {AuthProvider} from "@refinedev/core" import type {AuthProvider, UpdatePasswordFormTypes} from "@refinedev/core"
import type { import type {
AuthActionResponse, AuthActionResponse,
@ -31,9 +31,8 @@ export type Identity = {
email: string; email: string;
} }
export type UpdatePasswordFormRequest = { export interface UpdatePasswordFormRequest extends UpdatePasswordFormTypes{
currentPassword: string; currentPassword: string;
newPassword: string;
} }
export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => { export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => {
@ -102,7 +101,7 @@ export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => {
async updatePassword(params: UpdatePasswordFormRequest): Promise<AuthActionResponse> { async updatePassword(params: UpdatePasswordFormRequest): Promise<AuthActionResponse> {
maybeSetupAuth(); 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) {
if (ret instanceof Error) { if (ret instanceof Error) {

View File

@ -29,6 +29,7 @@ import { Input } from "~/components/ui/input";
import { UsageCard } from "~/components/usage-card"; import { UsageCard } from "~/components/usage-card";
import QRImg from "~/images/QR.png"; import QRImg from "~/images/QR.png";
import {UpdatePasswordFormRequest} from "~/data/auth-provider.js";
export default function MyAccount() { export default function MyAccount() {
const { data: identity } = useGetIdentity<{ email: string }>(); const { data: identity } = useGetIdentity<{ email: string }>();
@ -292,7 +293,7 @@ const ChangePasswordForm = ({
open: boolean; open: boolean;
setOpen: (value: boolean) => void; setOpen: (value: boolean) => void;
}) => { }) => {
const { mutate: updatePassword } = useUpdatePassword<{ password: string }>(); const { mutate: updatePassword } = useUpdatePassword<UpdatePasswordFormRequest>();
const [form, fields] = useForm({ const [form, fields] = useForm({
id: "login", id: "login",
constraint: getZodConstraint(ChangePasswordSchema), constraint: getZodConstraint(ChangePasswordSchema),
@ -306,6 +307,7 @@ const ChangePasswordForm = ({
const data = Object.fromEntries(new FormData(e.currentTarget).entries()); const data = Object.fromEntries(new FormData(e.currentTarget).entries());
updatePassword({ updatePassword({
currentPassword: data.currentPassword.toString(),
password: data.newPassword.toString(), password: data.newPassword.toString(),
}); });
}, },