From 1aff1be8cd669bca1e97b8b1b328506d5e251aaf Mon Sep 17 00:00:00 2001 From: Zeke Zhang <958414905@qq.com> Date: Mon, 21 Apr 2025 21:03:00 +0800 Subject: [PATCH] fix(auth): update email configuration to use notification channel and add system settings to reset password email --- .../VariableInput/hooks/useSystemSettingsVariable.ts | 6 ------ .../plugin-auth/src/server/__tests__/lostPassword.test.ts | 4 ++-- .../plugins/@nocobase/plugin-auth/src/server/basic-auth.ts | 6 ++++++ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/core/client/src/schema-settings/VariableInput/hooks/useSystemSettingsVariable.ts b/packages/core/client/src/schema-settings/VariableInput/hooks/useSystemSettingsVariable.ts index ea1f8f9a45..e82e625869 100644 --- a/packages/core/client/src/schema-settings/VariableInput/hooks/useSystemSettingsVariable.ts +++ b/packages/core/client/src/schema-settings/VariableInput/hooks/useSystemSettingsVariable.ts @@ -28,12 +28,6 @@ export const useSystemSettingsVariable = () => { label: t('System title'), isLeaf: true, }, - { - key: 'logo', - value: 'logo', - label: t('Logo (URL)'), - isLeaf: true, - }, ] }; diff --git a/packages/plugins/@nocobase/plugin-auth/src/server/__tests__/lostPassword.test.ts b/packages/plugins/@nocobase/plugin-auth/src/server/__tests__/lostPassword.test.ts index d01cc6366b..cfd60d7045 100644 --- a/packages/plugins/@nocobase/plugin-auth/src/server/__tests__/lostPassword.test.ts +++ b/packages/plugins/@nocobase/plugin-auth/src/server/__tests__/lostPassword.test.ts @@ -48,7 +48,7 @@ describe('auth:lostPassword', () => { public: { enableResetPassword: true, }, - emailChannel: 'email', + notificationChannel: 'email', emailSubject: 'Reset your password', emailContentType: 'html', emailContentHTML: 'Click the link to reset your password: {{$resetLink}}', @@ -212,7 +212,7 @@ describe('auth:lostPassword', () => { public: { enableResetPassword: true, }, - emailChannel: 'email', + notificationChannel: 'email', emailSubject: 'Reset password for {{$user.username}}', emailContentType: 'html', emailContentHTML: 'Click the link to reset your password: {{$user.username}}', diff --git a/packages/plugins/@nocobase/plugin-auth/src/server/basic-auth.ts b/packages/plugins/@nocobase/plugin-auth/src/server/basic-auth.ts index f1b50934a4..9c62c48c69 100644 --- a/packages/plugins/@nocobase/plugin-auth/src/server/basic-auth.ts +++ b/packages/plugins/@nocobase/plugin-auth/src/server/basic-auth.ts @@ -193,6 +193,8 @@ export class BasicAuth extends BaseAuth { // 构建重置密码链接 const resetLink = `${baseURL}/reset-password?resetToken=${resetToken}`; + const systemSettings = await ctx.db.getRepository('systemSettings')?.findOne() || {}; + // 通过通知管理插件发送邮件 const notificationManager = ctx.app.getPlugin('notification-manager'); if (notificationManager) { @@ -204,6 +206,8 @@ export class BasicAuth extends BaseAuth { $resetLink: resetLink, $nDate: getDateVars(), $env: ctx.app.environment.getVariables(), + $resetLinkExpiration: resetTokenExpiresIn, + $systemSettings: systemSettings, }); const parsedContent = parsedValue(emailContentType === 'html' ? emailContentHTML : emailContentText, { @@ -211,6 +215,8 @@ export class BasicAuth extends BaseAuth { $resetLink: resetLink, $nDate: getDateVars(), $env: ctx.app.environment.getVariables(), + $resetLinkExpiration: resetTokenExpiresIn, + $systemSettings: systemSettings, }); const content = emailContentType === 'html' ? { html: parsedContent } : { text: parsedContent };