sdk: 登录
This commit is contained in:
@@ -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
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user