Explorar o código

♻️ refactor(auth): 移除登录时自动创建admin账号的逻辑

- 注释掉auth.service.ts中登录时自动创建admin用户的代码块
- 注释掉auth.service.mt.ts中登录时自动创建admin用户的代码块
- 改为手动管理admin账号,提高安全性
yourname hai 1 mes
pai
achega
a1020a80ef

+ 4 - 4
packages/auth-module/src/services/auth.service.ts

@@ -40,10 +40,10 @@ export class AuthService {
 
   async login(username: string, password: string): Promise<{ token: string; user: any }> {
     try {
-      // 确保admin用户存在
-      if (username === ADMIN_USERNAME) {
-        await this.ensureAdminExists();
-      }
+      // 注释掉自动创建admin账号功能
+      // if (username === ADMIN_USERNAME) {
+      //   await this.ensureAdminExists();
+      // }
 
       const user = await this.userService.getUserByUsername(username);
       if (!user) {

+ 4 - 4
packages/core-module-mt/auth-module-mt/src/services/auth.service.mt.ts

@@ -47,10 +47,10 @@ export class AuthService {
 
   async login(username: string, password: string, tenantId?: number): Promise<{ token: string; user: any }> {
     try {
-      // 确保admin用户存在
-      if (username === ADMIN_USERNAME) {
-        await this.ensureAdminExists(tenantId);
-      }
+      // 注释掉自动创建admin账号功能
+      // if (username === ADMIN_USERNAME) {
+      //   await this.ensureAdminExists(tenantId);
+      // }
 
       const user = await this.userService.getUserByUsername(username, tenantId);
       if (!user) {