mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
Fix password reset
This commit is contained in:
parent
51665a4162
commit
f21e17114a
@ -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(),
|
||||
|
||||
@ -445,16 +445,19 @@ export class StackClientInterface {
|
||||
}
|
||||
|
||||
async resetPassword(
|
||||
options: { code: string } & ({ password: string } | { onlyVerifyCode: boolean })
|
||||
options: { code: string } & ({ password: string } | { onlyVerifyCode: true })
|
||||
): Promise<KnownErrors["VerificationCodeError"] | undefined> {
|
||||
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]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user