mirror of
https://github.com/hanzoai/sign.git
synced 2026-10-21 01:21:51 +00:00
The product is branded Hanzo eSign (esign.hanzo.ai, repo hanzoai/esign). Rename all workspace packages @hanzo/sign-* → @hanzo/esign-* (1052 files) and align docker/Dockerfile turbo --scope/--filter to the actual remix package name @hanzo/esign (was a pre-existing mismatch with -remix that broke the build). Protected deps (@hanzo/insights, @hanzo/logo) untouched.
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import { createElement } from 'react';
|
|
|
|
import { mailer } from '@hanzo/esign-email/mailer';
|
|
import { ResetPasswordTemplate } from '@hanzo/esign-email/templates/reset-password';
|
|
import { prisma } from '@hanzo/esign-prisma';
|
|
|
|
import { NEXT_PUBLIC_WEBAPP_URL } from '../../constants/app';
|
|
import { env } from '../../utils/env';
|
|
import { renderEmailWithI18N } from '../../utils/render-email-with-i18n';
|
|
|
|
export interface SendResetPasswordOptions {
|
|
userId: number;
|
|
}
|
|
|
|
export const sendResetPassword = async ({ userId }: SendResetPasswordOptions) => {
|
|
const user = await prisma.user.findFirstOrThrow({
|
|
where: {
|
|
id: userId,
|
|
},
|
|
});
|
|
|
|
const assetBaseUrl = NEXT_PUBLIC_WEBAPP_URL() || 'http://localhost:3000';
|
|
|
|
const template = createElement(ResetPasswordTemplate, {
|
|
assetBaseUrl,
|
|
userEmail: user.email,
|
|
userName: user.name || '',
|
|
});
|
|
|
|
const [html, text] = await Promise.all([
|
|
renderEmailWithI18N(template),
|
|
renderEmailWithI18N(template, { plainText: true }),
|
|
]);
|
|
|
|
return await mailer.sendMail({
|
|
to: {
|
|
address: user.email,
|
|
name: user.name || '',
|
|
},
|
|
from: {
|
|
name: env('NEXT_PRIVATE_SMTP_FROM_NAME') || 'Hanzo eSign',
|
|
address: env('NEXT_PRIVATE_SMTP_FROM_ADDRESS') || '[email protected]',
|
|
},
|
|
subject: 'Password Reset Success!',
|
|
html,
|
|
text,
|
|
});
|
|
};
|