sdk: 登录

This commit is contained in:
luying
2021-11-08 17:47:30 +08:00
parent a251ce47fa
commit fb6a5a785e
12 changed files with 291 additions and 60 deletions

View File

@@ -61,4 +61,10 @@ export default class AccountController extends Controller {
const { name, idNum } = ctx.request.body;
ctx.body = await ctx.service.auth.authentication(name, idNum);
}
public async channelLogin() {
const { ctx } = this;
const { channelType, pst, clientId, deviceId, platform, pkgName, serverType, getuiCID } = ctx.request.body;
ctx.body = await ctx.service.auth.channelLogin(channelType, clientId, pst, deviceId, platform, pkgName, serverType, getuiCID);
}
}

View File

@@ -104,7 +104,7 @@ export default class GameController extends Controller {
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { isOK: true });
return;
} catch (e) {
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { isOK: false, err: e.stack });
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { isOK: false, err: (<Error>e).stack });
return;
}
}

View File

@@ -7,6 +7,7 @@ export default (app: Application) => {
router.get('/dev', controller.home.dev);
router.get('/dev/smscode', controller.account.getSmsCode);
router.get('/', controller.home.index);
router.post('/user/channellogin', controller.account.channelLogin);
router.post('/user/devicelogin', controller.account.deviceLogin);
router.post('/user/getsms', controller.account.getSms);
router.post('/user/smslogin', controller.account.smsLogin);

View File

@@ -13,6 +13,8 @@ import { resResult } from '../pubUtils/util';
import { checkTeeanAgerTime } from '../pubUtils/authenticateUtil';
import { authenticate } from '../pubUtils/httpUtil';
import { checkTask } from 'app/pubUtils/taskUtil';
import { getChannelId, loginValidata } from '../pubUtils/sdkUtil';
import { LoginValidateData37 } from 'app/domain/sdk';
/**
* Test Service
@@ -381,4 +383,46 @@ export default class Auth extends Service {
let date = idNum.slice(12, 14);
return `${year}-${month}-${date}`;
}
/**
* 渠道服登录
* @param channelType 渠道类型 37: '37'
* @param clientId
* @param pst
* @param deviceId
* @param platform
* @param pkgName
* @param serverType
* @param getuiCID
* @returns
*/
public async channelLogin(channelType: string, clientId: string, pst: string, deviceId: string, platform: string, pkgName: string, serverType: string, getuiCID: string) {
const ctx = this.ctx;
const ip = ctx.request.ip;
let requestResult = await loginValidata(channelType, clientId, pst)
if(!requestResult) return this.ctx.service.utils.resResult(STATUS.CHANNEL_ERR);
if(requestResult.code != 1) {
return this.ctx.service.utils.resResult(STATUS.VALIDATE_ERR, requestResult);
}
let channelId = getChannelId(channelType, requestResult.data.uid);
const token = ctx.service.utils.generateStr(256);
let user = await UserModel.createOrUpdateChannelUser(channelId, channelType, requestResult.data, token, platform, pkgName, serverType, deviceId, ip);
if (getuiCID) {//更新个推cid
await UserModel.updateGetuiCIDByChannel(channelId, getuiCID);
}
let channelInfo: any = {};
if(channelType == '37') {
channelInfo.uid = (<LoginValidateData37>user.channelInfo).uid;
}
return ctx.service.utils.resResult(STATUS.SUCCESS, {
canLogin: true,
channelId,
token: user.token,
userCode: user.userCode,
channelInfo
});
}
}