|
@@ -41,60 +41,25 @@ class LoginService extends CrudService {
|
|
if (_user === '') {
|
|
if (_user === '') {
|
|
throw new BusinessError(ErrorCode.USER_NOT_EXIST);
|
|
throw new BusinessError(ErrorCode.USER_NOT_EXIST);
|
|
// throw new BusinessError(ErrorCode.BAD_PASSWORD);
|
|
// throw new BusinessError(ErrorCode.BAD_PASSWORD);
|
|
|
|
+ }else{
|
|
|
|
+ if(role === '3'){
|
|
|
|
+ const operationlogdata = { login_id: user.id, login_name: user.name, login_role: user.role, type: '0', operation_edit: '登录' };
|
|
|
|
+ const url = 'http://127.0.0.1:9004/api/market/operationlog/';
|
|
|
|
+ const operationlog = await this.ctx.curl(url, {
|
|
|
|
+ method: 'post',
|
|
|
|
+ headers: {
|
|
|
|
+ 'content-type': 'application/json',
|
|
|
|
+ },
|
|
|
|
+ dataType: 'json',
|
|
|
|
+ data: JSON.stringify(operationlogdata),
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- // 将用户输入的密码进行加密并与查询到的用户数据密码相比对
|
|
|
|
- // const pas = await this.createJwtPwd(passwd);
|
|
|
|
- // // 如果两个密码不一致抛出异常
|
|
|
|
- // if (pas !== _user.passwd.secret) {
|
|
|
|
- // throw new BusinessError(ErrorCode.BAD_PASSWORD);
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // if (role === '3') {
|
|
|
|
- // console.log('vip用户');
|
|
|
|
- // } else if (role === '8') {
|
|
|
|
- // console.log('展会vip用户');
|
|
|
|
- // } else {
|
|
|
|
- // console.log('无此展会');
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // if (_user.role === '3' || _user.role === '8') {
|
|
|
|
- // const url = 'http://127.0.0.1:9004/api/market/user/' + _user.uid;
|
|
|
|
- // const marketuser = await this.ctx.curl(url, {
|
|
|
|
- // method: 'get',
|
|
|
|
- // headers: {
|
|
|
|
- // 'content-type': 'application/json',
|
|
|
|
- // },
|
|
|
|
- // dataType: 'json',
|
|
|
|
- // });
|
|
|
|
- // if (marketuser.data.data.status !== '1') {
|
|
|
|
- // throw new BusinessError(ErrorCode.ACCESS_DENIED);
|
|
|
|
- // }
|
|
|
|
- // } else if (_user.role === '6') {
|
|
|
|
- // const url = 'http://127.0.0.1:9004/api/market/expertsuser/' + _user.uid;
|
|
|
|
- // const expertsuser = await this.ctx.curl(url, {
|
|
|
|
- // method: 'get',
|
|
|
|
- // headers: {
|
|
|
|
- // 'content-type': 'application/json',
|
|
|
|
- // },
|
|
|
|
- // dataType: 'json',
|
|
|
|
- // });
|
|
|
|
- // if (expertsuser.data.data.status !== '1') {
|
|
|
|
- // throw new BusinessError(ErrorCode.ACCESS_DENIED);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
|
|
+
|
|
// 取出用户的类型,根据用户类型返回相应信息
|
|
// 取出用户的类型,根据用户类型返回相应信息
|
|
const state = uuid();
|
|
const state = uuid();
|
|
const key = `free:auth:state:${state}`;
|
|
const key = `free:auth:state:${state}`;
|
|
- // const _menus = [];
|
|
|
|
- // for (const elm of user.menus) {
|
|
|
|
- // const _menu = await this.rmodel.findById({ _id: ObjectId(elm) });
|
|
|
|
- // if (_menu) {
|
|
|
|
- // _menus.push({ id: elm, role_name: _menu.role_name, url: _menu.url });
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // user.menus = JSON.stringify(_menus);
|
|
|
|
- console.log(user);
|
|
|
|
|
|
+
|
|
const token = await this.createJwt(user);
|
|
const token = await this.createJwt(user);
|
|
await this.app.redis.set(key, token, 'EX', 60 * 60 * 24);
|
|
await this.app.redis.set(key, token, 'EX', 60 * 60 * 24);
|
|
return { key };
|
|
return { key };
|