fixed email url bug

This commit is contained in:
Zai Shi 2024-03-07 23:03:21 +08:00
parent 27805d8dfb
commit 3e181bcb86
4 changed files with 11 additions and 5 deletions

View File

@ -105,7 +105,7 @@ export const POST = smartRouteHandler(async (req: NextRequest) => {
throw new KnownError(RedirectUrlInvalidErrorCode);
}
await sendVerificationEmail(projectId, newUser.projectUserId, emailVerificationRedirectUrl,);
await sendVerificationEmail(projectId, newUser.projectUserId, emailVerificationRedirectUrl);
return NextResponse.json({
access_token: accessToken,

View File

@ -128,9 +128,12 @@ export async function sendVerificationEmail(
}
});
const verificationUrl = new URL(redirectUrl);
verificationUrl.searchParams.append('code', verificationCode.code);
const html = render(
<VerificationEmail
verificationUrl={`${getEnvVariable('NEXT_PUBLIC_STACK_URL')}/api/v1/auth/verify-email?code=${verificationCode.code}`}
verificationUrl={verificationUrl.toString()}
projectName={project.displayName}
username={projectUser.displayName || undefined}
fromStack={emailConfig.type === 'shared'}

View File

@ -139,12 +139,12 @@ export async function signUpWithCredential(
email,
password,
redirectUrl,
emailVerificationRedirectUrl = "/"
emailVerificationRedirectUrl,
}: {
email: string,
password: string,
redirectUrl?: string,
emailVerificationRedirectUrl?: string,
emailVerificationRedirectUrl: string,
}
): Promise<SignUpErrorCode | undefined>{
emailVerificationRedirectUrl = constructRedirectUrl(emailVerificationRedirectUrl);

View File

@ -539,7 +539,10 @@ class _StackClientAppImpl<HasTokenStore extends boolean, ProjectId extends strin
}
this._ensurePersistentTokenStore();
const tokenStore = getTokenStore(this._tokenStoreOptions);
return await signUpWithCredential(this._interface, tokenStore, options);
return await signUpWithCredential(this._interface, tokenStore, {
...options,
emailVerificationRedirectUrl: this.urls.emailVerification,
});
}
async callOAuthCallback(options: {