🐞 fix(37需求): 账号多开

This commit is contained in:
luying
2023-05-25 16:33:40 +08:00
parent 0b2dbabfd8
commit 42c9397349
2 changed files with 12 additions and 10 deletions

View File

@@ -55,8 +55,16 @@ export class EntryHandler {
console.log('user token not found');
return resResult(STATUS.TOKEN_ERR);
}
let onlineRoleId = await getOnlineRoleByUserCode(user.userCode);
let ip = this.getIp(session);
let isWhiteList = await checkWhiteList(pinus.app.get('env'), ip, user.uid);
let ipLocation = await getIpLocation(ip);
let role = await RoleModel.findByUidAndSetTime(user.uid, serverId, ip, ipLocation, null, true);
if (!role) {
return resResult(STATUS.ROLE_NOT_FOUND);
}
let onlineRoleId = isWhiteList? role.roleId: await getOnlineRoleByUserCode(user.userCode);
if (!!onlineRoleId) { // 多地登陆踢下线
let connect = await getRoleOnlineInfo(onlineRoleId);
if (connect.sid = self.app.getServerId()) {
@@ -66,10 +74,8 @@ export class EntryHandler {
}
}
let ip = this.getIp(session);
let server = await ServerlistModel.findByServerId(serverId);
if(!server) return resResult(STATUS.SERVER_NOT_FOUND);
let isWhiteList = await checkWhiteList(pinus.app.get('env'), ip, user.uid);
if(!isWhiteList) { // 白名单
if(server.openTime > nowSeconds()) {
return resResult(STATUS.SERVER_IS_NOT_OPEN);
@@ -85,12 +91,6 @@ export class EntryHandler {
}
}
let ipLocation = await getIpLocation(ip);
let role = await RoleModel.findByUidAndSetTime(user.uid, serverId, ip, ipLocation, null, true);
if (!role) {
return resResult(STATUS.ROLE_NOT_FOUND);
}
let serverName = this.app.getServerId();
await roleLogin(role.roleId, user.userCode, serverName, role.createTime, role.serverId, role.lv, role.topLineupCe); // 保存在线用户