|
@@ -17,25 +17,16 @@ class LoginService extends CrudService {
|
|
|
|
|
|
// 用户登录
|
|
|
async login(data) {
|
|
|
- const { phone, passwd, role, institution_code } = data;
|
|
|
+ const { phone, passwd, role } = data;
|
|
|
// 根据用户输入的手机号查询其他用户表中是否存在相应数据
|
|
|
let user = await this.model.findOne({ phone, role });
|
|
|
// 增设使用code模式登陆的判断变量
|
|
|
let is_code = false;
|
|
|
// 如果用户不存在抛出异常
|
|
|
if (!user) {
|
|
|
- // role为5的时候需要组织机构代码登陆
|
|
|
- if (role === '5') {
|
|
|
- user = await this.model.findOne({ code: phone, role, institution_code });
|
|
|
- } else {
|
|
|
- // 添加code作为登录的方式
|
|
|
- user = await this.model.findOne({ code: phone, role });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (!user) {
|
|
|
- throw new BusinessError(ErrorCode.USER_NOT_EXIST);
|
|
|
- } else is_code = true;
|
|
|
+ // 添加code作为登录的方式
|
|
|
+ user = await this.model.findOne({ code: phone, role });
|
|
|
+ if (!user) { throw new BusinessError(ErrorCode.USER_NOT_EXIST); } else is_code = true;
|
|
|
}
|
|
|
const pdata = {};
|
|
|
if (is_code) pdata.code = phone;
|