diff --git a/packages/ui/certd-client/src/views/framework/forgot-password/index.vue b/packages/ui/certd-client/src/views/framework/forgot-password/index.vue index 9411659ef..6ce06b27d 100644 --- a/packages/ui/certd-client/src/views/framework/forgot-password/index.vue +++ b/packages/ui/certd-client/src/views/framework/forgot-password/index.vue @@ -76,7 +76,7 @@ 找回密码
- 管理员无绑定通信方式或MFA丢失找回 + 管理员忘记密码 返回登录
diff --git a/packages/ui/certd-client/src/views/framework/login/index.vue b/packages/ui/certd-client/src/views/framework/login/index.vue index 1b971806a..7ac1ae5fc 100644 --- a/packages/ui/certd-client/src/views/framework/login/index.vue +++ b/packages/ui/certd-client/src/views/framework/login/index.vue @@ -59,6 +59,9 @@ {{ t("authentication.forgotPassword") }} + + {{ t("authentication.forgotPassword") }} + diff --git a/packages/ui/certd-server/src/middleware/reset-passwd/middleware.ts b/packages/ui/certd-server/src/middleware/reset-passwd/middleware.ts index c8b342712..f01ebe6bc 100644 --- a/packages/ui/certd-server/src/middleware/reset-passwd/middleware.ts +++ b/packages/ui/certd-server/src/middleware/reset-passwd/middleware.ts @@ -33,21 +33,6 @@ export class ResetPasswdMiddleware implements IWebMiddleware { @Init() async init() { - if (this.resetAdminPasswd === true) { - logger.info('开始重置1号管理员用户的密码'); - const newPasswd = '123456'; - await this.userService.resetPassword(1, newPasswd); - await this.userService.updateStatus(1, 1); - await this.userSettingsService.deleteWhere({ - userId: 1, - key:"user.two.factor" - }) - const publicSettings = await this.sysSettingsService.getPublicSettings() - publicSettings.captchaEnabled = false - await this.sysSettingsService.savePublicSettings(publicSettings); - - const user = await this.userService.info(1); - logger.info(`重置1号管理员用户的密码完成,2FA设置已删除,验证码登录已禁用,用户名:${user.username},新密码:${newPasswd},请在登录进去之后尽快修改密码`); - } + } } diff --git a/packages/ui/certd-server/src/modules/auto/auto-z.ts b/packages/ui/certd-server/src/modules/auto/auto-z.ts index d91777c40..0d12b5e14 100644 --- a/packages/ui/certd-server/src/modules/auto/auto-z.ts +++ b/packages/ui/certd-server/src/modules/auto/auto-z.ts @@ -7,6 +7,8 @@ import { getVersion } from '../../utils/version.js'; import dayjs from 'dayjs'; import { Application } from '@midwayjs/koa'; import { httpsServer, HttpsServerOptions } from './https/server.js'; +import { UserService } from '../sys/authority/service/user-service.js'; +import { UserSettingsService } from '../mine/service/user-settings-service.js'; @Autoload() @Scope(ScopeEnum.Request, { allowDowngrade: true }) @@ -22,6 +24,15 @@ export class AutoZPrint { @Config('koa') koaConfig: any; + @Inject() + userService: UserService; + + @Inject() + userSettingsService: UserSettingsService; + + @Config('system.resetAdminPasswd') + private resetAdminPasswd: boolean; + @Init() async init() { //监听https @@ -41,6 +52,26 @@ export class AutoZPrint { } logger.info('Certd已启动'); logger.info('========================================='); + await this.resetPasswd(); + } + + async resetPasswd(){ + if (this.resetAdminPasswd === true) { + logger.info('开始重置1号管理员用户的密码'); + const newPasswd = '123456'; + await this.userService.resetPassword(1, newPasswd); + await this.userService.updateStatus(1, 1); + await this.userSettingsService.deleteWhere({ + userId: 1, + key:"user.two.factor" + }) + const publicSettings = await this.sysSettingsService.getPublicSettings() + publicSettings.captchaEnabled = false + await this.sysSettingsService.savePublicSettings(publicSettings); + + const user = await this.userService.info(1); + logger.info(`重置1号管理员用户的密码完成,2FA设置已删除,验证码登录已禁用,用户名:${user.username},新密码:${newPasswd},请在登录进去之后尽快修改密码`); + } } startHeapLog() {