The Open Source DocuSign Alternative.
TypeScript digital-signaturedocument-signingdocusign-alternativee-signatureesignesignaturenext-authnextjsopen-sourcepades-standardpdfpdf-signpdf-signaturepostgresqlprismaself-hostedsigningtypescript
fix: guard missing password reset token and fix broken reset link URL (#2928)
Arun Kumar184cbd6770fa
diff --git a/packages/lib/server-only/auth/send-forgot-password.ts b/packages/lib/server-only/auth/send-forgot-password.tsindex b97ef1b35..c29d92b54 100644--- a/packages/lib/server-only/auth/send-forgot-password.ts+++ b/packages/lib/server-only/auth/send-forgot-password.ts@@ -32,9 +32,12 @@ export const sendForgotPassword = async ({ userId }: SendForgotPasswordOptions)throw new Error('User not found');}- const token = user.passwordResetTokens[0].token;+ const token = user.passwordResetTokens[0]?.token;+ if (!token) {+ throw new Error('Password reset token not found for user');+ }const assetBaseUrl = NEXT_PUBLIC_WEBAPP_URL() || 'http://localhost:3000';- const resetPasswordLink = `${NEXT_PUBLIC_WEBAPP_URL()}/reset-password/${token}`;+ const resetPasswordLink = `${assetBaseUrl}/reset-password/${token}`;const template = createElement(ForgotPasswordTemplate, {assetBaseUrl,