Ver código fonte

修改密码登录

zs 8 meses atrás
pai
commit
b1b9373523
1 arquivos alterados com 2 adições e 3 exclusões
  1. 2 3
      src/service/login.service.ts

+ 2 - 3
src/service/login.service.ts

@@ -87,15 +87,14 @@ export class LoginService {
       if (!role) throw new ServiceError(ErrorCode.ROLE_IS_DISABLED);
       if (!role) throw new ServiceError(ErrorCode.ROLE_IS_DISABLED);
     }
     }
   }
   }
-  // 随机密码
+  // 修改密码
   async updatePwd(data: UPwdDTO, type: LoginType) {
   async updatePwd(data: UPwdDTO, type: LoginType) {
     let model;
     let model;
     if (type === LoginType.Admin) model = this.adminModel;
     if (type === LoginType.Admin) model = this.adminModel;
     else model = this.userModel;
     else model = this.userModel;
     const user = await model.findOne({ where: { id: Equal(data.id) } });
     const user = await model.findOne({ where: { id: Equal(data.id) } });
     if (!user) new ServiceError(ErrorCode.USER_NOT_FOUND);
     if (!user) new ServiceError(ErrorCode.USER_NOT_FOUND);
-    user.password = data.password;
-    await user.save();
+    await model.update({ id: data.id }, { password: data.password });
   }
   }
 
 
   // 需要改的时候再用
   // 需要改的时候再用