登录:防旧包登录
This commit is contained in:
@@ -17,8 +17,10 @@ export const STATUS = {
|
||||
FUNCTION_CLOSE: { code: 14, simStr: '抱歉,该功能暂时关闭' },
|
||||
TIMESTAMP_ERR: { code: 15, simStr: '请求时间参数错误' },
|
||||
DUPLICATE_ACCESS: { code: 16, simStr: '随机请求参数重复' },
|
||||
ADDRESS_ERR: { code: 17, simStr: '您的版本已停止支持,请前往应用商店下载最新安装包' },
|
||||
GLOBAL_ERR: { code: 1003, simStr: '服务器内部错误' },
|
||||
UPDATE_INFO_ERR: {code: 1004, simStr: '热更新配置错误'},
|
||||
|
||||
// http请求
|
||||
REQUEST_TIME_OUT: { code: 2000, simStr: '请求超时' },
|
||||
REQUEST_FAIL: { code: 2001, simStr: '请求错误' },
|
||||
|
||||
@@ -24,9 +24,6 @@ export default class Region extends BaseModel {
|
||||
@prop({ required: true })
|
||||
env: string; // 环境变量
|
||||
|
||||
@prop({ required: true })
|
||||
addressType: number; // 环境变量
|
||||
|
||||
@prop({ required: true })
|
||||
gmLink: string; // 短链接地址
|
||||
|
||||
@@ -54,6 +51,9 @@ export default class Region extends BaseModel {
|
||||
@prop({ required: true })
|
||||
latestServerUniqId: number; // 最新服唯一id
|
||||
|
||||
@prop({ required: true })
|
||||
addressType: number; // 参数表的那个addressType
|
||||
|
||||
@prop({ required: true })
|
||||
serverCount: number; // 总数
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { dispatch } from 'app/pubUtils/dispatcher';
|
||||
import { RedisClient } from 'redis';
|
||||
import { REDIS_KEY } from '@consts';
|
||||
import { RegionModel } from '@db/Region';
|
||||
import { getRandEelmWithWeight, resResult } from 'app/pubUtils/util';
|
||||
import { getRandEelmWithWeight } from 'app/pubUtils/util';
|
||||
import { ChannelInfoModel } from '@db/ChannelInfo';
|
||||
|
||||
export default class GameController extends Controller {
|
||||
@@ -20,7 +20,9 @@ export default class GameController extends Controller {
|
||||
const { version } = ctx.request.body;
|
||||
|
||||
let curRegion = await RegionModel.findRegionByEnv(this.app.config.realEnv);
|
||||
if(!curRegion) return resResult(STATUS.VERSION_ERR);
|
||||
if(!curRegion) {
|
||||
return ctx.body = ctx.service.utils.resResult(STATUS.VERSION_ERR);
|
||||
}
|
||||
|
||||
const versionFlag = ctx.service.utils.compareVersion(version, curRegion.versionCode);
|
||||
if (versionFlag >= 0) {
|
||||
@@ -34,10 +36,16 @@ export default class GameController extends Controller {
|
||||
|
||||
public async checkReview() {
|
||||
const { ctx } = this;
|
||||
const { version, platformAppid, platformAppId } = ctx.request.body;
|
||||
const { version, platformAppid, platformAppId, addressType } = ctx.request.body;
|
||||
|
||||
let curRegion = await RegionModel.findRegionByEnv(this.app.config.realEnv);
|
||||
if(!curRegion) return resResult(STATUS.VERSION_ERR);
|
||||
if(!curRegion) {
|
||||
return ctx.body = ctx.service.utils.resResult(STATUS.VERSION_ERR);
|
||||
}
|
||||
|
||||
if(curRegion.addressType != addressType) {
|
||||
return ctx.body = ctx.service.utils.resResult(STATUS.ADDRESS_ERR);
|
||||
}
|
||||
|
||||
let hasPolicy = false, userPolicyLink = '', privacyPolicyLink = ''; // 是否需要替换协议,有就是用下面两个字段替换
|
||||
let platform = platformAppid ?? platformAppId;
|
||||
@@ -65,12 +73,18 @@ export default class GameController extends Controller {
|
||||
try {
|
||||
const { ctx } = this;
|
||||
let { uid } = ctx;
|
||||
const { version } = ctx.request.body;
|
||||
const { version, addressType } = ctx.request.body;
|
||||
let serverList = new Array<GroupParam>();
|
||||
let loginServerList = new Array<ServerParamWithRole>();
|
||||
|
||||
let curRegion = await RegionModel.findRegionByEnv(this.app.config.realEnv);
|
||||
if(!curRegion) return resResult(STATUS.VERSION_ERR);
|
||||
if(!curRegion) {
|
||||
return ctx.body = ctx.service.utils.resResult(STATUS.VERSION_ERR);
|
||||
}
|
||||
|
||||
if(curRegion.addressType != addressType) {
|
||||
return ctx.body = ctx.service.utils.resResult(STATUS.ADDRESS_ERR);
|
||||
}
|
||||
|
||||
let isReview = await ctx.service.update.checkReview(curRegion, version);
|
||||
let env = isReview? curRegion.reviewEnv: ctx.app.config.realEnv;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Controller } from 'egg';
|
||||
import { RegionModel } from '@db/Region';
|
||||
import { STATUS } from '@consts';
|
||||
|
||||
export default class UpdateController extends Controller {
|
||||
public async getversion() {
|
||||
@@ -10,9 +11,16 @@ export default class UpdateController extends Controller {
|
||||
|
||||
public async getUpdateUrl() {
|
||||
const { ctx } = this;
|
||||
const { addressType } = ctx.request.body;
|
||||
|
||||
const env = this.app.config.realEnv;
|
||||
const curRegion = await RegionModel.findRegionByEnv(env);
|
||||
const { curVersion, updateResUrl } = curRegion;
|
||||
const { curVersion, updateResUrl, addressType: originAddressType } = curRegion;
|
||||
|
||||
if(originAddressType != addressType) {
|
||||
return ctx.body = ctx.service.utils.resResult(STATUS.ADDRESS_ERR);
|
||||
}
|
||||
|
||||
ctx.body = await ctx.service.update.getUpdateUrl(env, curVersion, updateResUrl);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user