diff --git a/apps/backend/src/route-handlers/verification-code-handler.tsx b/apps/backend/src/route-handlers/verification-code-handler.tsx index 8a0508c3d..0fdc87857 100644 --- a/apps/backend/src/route-handlers/verification-code-handler.tsx +++ b/apps/backend/src/route-handlers/verification-code-handler.tsx @@ -71,7 +71,7 @@ export function createVerificationCodeHandler< code: yupString().required(), // we cast to undefined as a typehack because the types are a bit icky // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - }).concat((verifyOnly ? null : options.requestBody) as undefined ?? yupObject({})).required(), + }).concat((verifyOnly ? undefined : options.requestBody) ?? yupObject({})).required(), }), response: verifyOnly ? yupObject({ statusCode: yupNumber().oneOf([200]).required(), diff --git a/packages/stack-shared/src/interface/clientInterface.ts b/packages/stack-shared/src/interface/clientInterface.ts index ae230fbab..b8e3de656 100644 --- a/packages/stack-shared/src/interface/clientInterface.ts +++ b/packages/stack-shared/src/interface/clientInterface.ts @@ -445,16 +445,19 @@ export class StackClientInterface { } async resetPassword( - options: { code: string } & ({ password: string } | { onlyVerifyCode: boolean }) + options: { code: string } & ({ password: string } | { onlyVerifyCode: true }) ): Promise { const res = await this.sendClientRequestAndCatchKnownError( - "/auth/password/reset", + "onlyVerifyCode" in options ? "/auth/password/reset/check-code" : "/auth/password/reset", { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify(options), + body: JSON.stringify({ + code: options.code, + ...("password" in options ? { password: options.password } : {}), + }), }, null, [KnownErrors.VerificationCodeError]