fixed send verification email

This commit is contained in:
Zai Shi 2024-07-25 11:20:40 -07:00 committed by Stan Wohlwend
parent 088e980c38
commit 71a7fcd6de
2 changed files with 10 additions and 7 deletions

View File

@ -356,7 +356,8 @@ export class StackClientInterface {
}
async sendVerificationEmail(
emailVerificationRedirectUrl: string,
email: string,
callbackUrl: string,
session: InternalSession
): Promise<KnownErrors["EmailAlreadyVerified"] | undefined> {
const res = await this.sendClientRequestAndCatchKnownError(
@ -367,7 +368,8 @@ export class StackClientInterface {
"Content-Type": "application/json"
},
body: JSON.stringify({
emailVerificationRedirectUrl,
email,
callback_url: callbackUrl,
}),
},
session,

View File

@ -804,7 +804,10 @@ class _StackClientAppImpl<HasTokenStore extends boolean, ProjectId extends strin
return app._updateClientUser(update, session);
},
sendVerificationEmail() {
return app._sendVerificationEmail(session);
if (!crud?.primary_email) {
throw new StackAssertionError("User does not have a primary email");
}
return app._sendVerificationEmail(crud.primary_email, session);
},
updatePassword(options: { oldPassword: string, newPassword: string}) {
return app._updatePassword(options, session);
@ -904,8 +907,6 @@ class _StackClientAppImpl<HasTokenStore extends boolean, ProjectId extends strin
}
}
console.log("HIIIIIIIIIIIII", handlerName, url, new Error());
await this._redirectIfTrusted(url, options);
}
@ -1097,9 +1098,9 @@ class _StackClientAppImpl<HasTokenStore extends boolean, ProjectId extends strin
await this.redirectToAfterSignOut();
}
protected async _sendVerificationEmail(session: InternalSession): Promise<KnownErrors["EmailAlreadyVerified"] | void> {
protected async _sendVerificationEmail(email: string, session: InternalSession): Promise<KnownErrors["EmailAlreadyVerified"] | void> {
const emailVerificationRedirectUrl = constructRedirectUrl(this.urls.emailVerification);
return await this._interface.sendVerificationEmail(emailVerificationRedirectUrl, session);
return await this._interface.sendVerificationEmail(email, emailVerificationRedirectUrl, session);
}
protected async _updatePassword(