提交 b5a31950 authored 作者: 钟是志's avatar 钟是志

离校移动端 接口上保证北电科 不被安全测评测出来

上级 59b7b9fd
......@@ -14,3 +14,20 @@ export function setCurrentUser(v){
sessionStorage.setItem('currentUser', JSON.stringify(v));
}
}
export const getUserInfo = () => {
let x = localStorage.getItem('user');
if (isJSON(x)) {
x = JSON.parse(x);
if (!x.groupsId) {
x.groupsId = 'pub';
x.differenceBetweenServerAndClientTime = 0;
}
return x;
} else {
return {
groupsId: 'pub',
differenceBetweenServerAndClientTime: 0,
};
}
};
// import { getCurrentUser, getToken } from '@/webPublic/one_stop_public/utils/token';
import Md5 from 'js-md5';
import { getCurrentUser } from '@/H5Public/utils/2022new/currentUser';
import {getCurrentUser, getUserInfo} from '@/H5Public/utils/2022new/currentUser';
import { getIsBei_Dian, getToken } from '@/H5Public/utils/authority';
import { getUrlParams } from '@/H5Public/utils/handleString';
const isTest = getUrlParams().test;
......@@ -9,7 +9,9 @@ const isTest = getUrlParams().test;
export function getHeaders(url = '') {
const token = getToken();
const currentInfo = getCurrentUser();
const timestamp = new Date().getTime() + window.differenceBetweenServerAndClientTime;
const onestopInfo = getUserInfo();
const id = currentInfo.xgUserId || onestopInfo.id;
const timestamp = onestopInfo.differenceBetweenServerAndClientTime ? new Date().getTime() + onestopInfo.differenceBetweenServerAndClientTime : new Date().getTime();
const secretString = token + currentInfo.xgUserId + timestamp;
const res = {
......@@ -18,21 +20,9 @@ export function getHeaders(url = '') {
},
};
if(getIsBei_Dian() && currentInfo?.userid){
if(getIsBei_Dian() && id){
res.headers.auth = Md5(secretString);
res.headers.timestamp = timestamp;
if (isTest) {
console.log(
{
secretString,
auth: res.headers.auth,
timestamp,
xgUserId: currentInfo.xgUserId,
typeString: currentInfo.typeString,
differenceBetweenServerAndClientTime: window.differenceBetweenServerAndClientTime,
},
);
}
}
return res;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论