🐞 fix(37需求): 账号多开
This commit is contained in:
@@ -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); // 保存在线用户
|
||||
|
||||
@@ -6,6 +6,7 @@ import { REDIS_KEY, SERVER_STATUS } from '@consts';
|
||||
import { getRedisSubChannel } from 'app/pubUtils/sdkUtil';
|
||||
import { ServerlistType } from '@db/Serverlist';
|
||||
import { nowSeconds } from 'app/pubUtils/timeUtil';
|
||||
import { checkWhiteList } from 'app/pubUtils/sysUtil';
|
||||
const csprng = require('csprng');
|
||||
/**
|
||||
* Utils Service
|
||||
@@ -63,8 +64,9 @@ export default class Utils extends Service {
|
||||
public async checkOnlineUser(userCode: string) {
|
||||
let redisClient: RedisClient = this.ctx.app.context.redisClient;
|
||||
let onlineRoleId = await redisClient.hgetAsync(REDIS_KEY.USER_CODE, userCode);
|
||||
let isWhiteList = await checkWhiteList(this.ctx.app.config.realEnv, this.ctx.clientIp, this.ctx.uid);
|
||||
|
||||
if (!!onlineRoleId) { // 多地登陆踢下线
|
||||
if (!isWhiteList && !!onlineRoleId) { // 多地登陆踢下线
|
||||
let str = await redisClient.hgetAsync(REDIS_KEY.ONLINE_USERS, onlineRoleId);
|
||||
|
||||
if(str) {
|
||||
|
||||
Reference in New Issue
Block a user