Commit c879f4e3 authored by 董加伟's avatar 董加伟

1

parent 73ddaeb1
Pipeline #48912 passed with stage
in 4 seconds
'use strict';
const Controller = require('egg').Controller;
const moment = require('moment');
class ResponseController extends Controller {
......@@ -21,7 +22,7 @@ class ResponseController extends Controller {
ctx.validate(rule, input_params);
if (input_params.user_token) {
const rule = {
auth_token: { type: 'string' },
auth_token: { type: 'string', required: false },
user_sid: { type: 'string' },
};
ctx.validate(rule, input_params);
......@@ -138,9 +139,10 @@ class ResponseController extends Controller {
node_user_center_login_ret.device_id = device_login_data.device_id;
node_user_center_login_ret.device_login_id = device_login_data.device_login_logs_id;
}
if (auth_token) node_user_center_login_ret.auth_token = auth_token;
if (user_sid && this.ctx.helper.encodeUserSid(oid) !== user_sid) node_user_center_login_ret.jianbing_customer_id = this.ctx.helper.encodeUserSid(input_params.user_sid);
if (user_sid && this.ctx.helper.encodeUserIdNew(oid) !== user_sid) {
node_user_center_login_ret.jianbing_customer_id = this.ctx.helper.encodeUserIdNew(user_sid);
node_user_center_login_ret.auth_token = ctx.helper.md5(String(node_user_center_login_ret.jianbing_customer_id) + moment(new Date()).format('MDYYYY') + 'f74jkdsy83sjf', 'utf8');
}
const expire = 7200 * 1000;
const date = new Date();
for (const key in node_user_center_login_ret) {
......
......@@ -524,6 +524,38 @@ module.exports = {
return rtn;
},
encodeUserIdNew(userId) {
const rand = 'OU1WjLvZCrRJ7Yo0gE2XDjuuaSAUuaH1bhHPuMymcdfEeKz0igRhXQkMuLTm1';
const randKey = 2019;
let rtn = '';
const code = userId << 2;
const randLength = 11;
const len = String(code).length;
const codeLen = rand.slice(0, randLength);
const codeNums = rand.slice(randLength, randLength + 12);
const codeExt = rand.slice(randLength + 12, rand.length);
const begin = codeLen.slice(len - 1, len);
const ext = randLength - len - 1;
let temp = String(Math.floor(code / randKey)).replace('.', '');
temp = temp.slice(-ext);
const arrExtTemp = codeExt.split('');
const arrExt = temp.split('');
for (const v of arrExt) {
rtn += arrExtTemp[v];
}
const arrNumsTemp = codeNums.split('');
const arrNums = String(code).split('');
for (const v of arrNums) {
rtn += arrNumsTemp[v];
}
rtn = String(userId).slice(0, 5) + begin + rtn;
return rtn;
},
// aes加密
async cipherByAES(data) {
const { ctx } = this;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment