|
@@ -96,19 +96,27 @@ class TrainliveService extends CrudService {
|
|
|
if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定的培训问诊信息!');
|
|
|
const user = object.user_data.find(f => f.user_phone === user_phone);
|
|
|
if (!user) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到培训问诊下该手机号的用户信息!');
|
|
|
- const is_login = await this.app.redis.get(`trainlive/${user._id}`);
|
|
|
+ // const is_login = await this.app.redis.get(`trainlive/${user._id}`);
|
|
|
+ const is_login = this.ctx.session[`trainlive/${user._id}`];
|
|
|
if (is_login) throw new BusinessError(ErrorCode.BUSINESS, '用户已登录');
|
|
|
if (user.user_password !== user_password) throw new BusinessError(ErrorCode.BAD_PASSWORD, '用户密码错误!');
|
|
|
- await this.app.redis.set(`trainlive/${user._id}`, user);
|
|
|
+ this.ctx.session[`trainlive/${user._id}`] = user;
|
|
|
+ // await this.app.redis.set(`trainlive/${user._id}`, user);
|
|
|
return user;
|
|
|
}
|
|
|
|
|
|
+ async userLonger({ id }) {
|
|
|
+ const is_login = this.ctx.session[`trainlive/${id}`];
|
|
|
+ if (!is_login) throw new BusinessError(ErrorCode.BUSINESS, '用户登陆已失效,请重新登陆');
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 参会人员注销
|
|
|
* @param {String} {id} 参会人员id
|
|
|
*/
|
|
|
async userLogout({ id }) {
|
|
|
- await this.app.redis.del(`trainlive/${id}`);
|
|
|
+ this.ctx.session[`trainlive/${id}`] = null;
|
|
|
+ // await this.app.redis.del(`trainlive/${id}`);
|
|
|
}
|
|
|
}
|
|
|
|