|
|
@@ -78,6 +78,7 @@ function checkHandleRequest() {
|
|
|
if ($request && $request.method != 'OPTIONS') {
|
|
|
switch (path) {
|
|
|
case '/rest/member/userInfo':
|
|
|
+ handleUserInfo();
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
@@ -85,11 +86,38 @@ function checkHandleRequest() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function getResponsePlainData() {
|
|
|
+ let data = magicJS.getResponseBody();
|
|
|
+ if (!data) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ return JSON.parse(data);
|
|
|
+ } catch(err){
|
|
|
+ magicJS.logger.error(err);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function handleHeaders() {
|
|
|
let headers = $request.headers;
|
|
|
+ magicJS.data.write('DIII_CaiLeYuan_Newrelic', headers['newrelic']);
|
|
|
+ magicJS.data.write('DIII_CaiLeYuan_apuid', headers['puid']);
|
|
|
+}
|
|
|
+
|
|
|
+function handleUserInfo() {
|
|
|
+ let rspData = getResponsePlainData();
|
|
|
+ if (!rspData) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (rspData.statusCode != 200) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ handleTokenAndCookie();
|
|
|
+}
|
|
|
+
|
|
|
+function handleTokenAndCookie() {
|
|
|
+ let headers = $request.headers;
|
|
|
if (headers['token']) {
|
|
|
- magicJS.data.write('DIII_CaiLeYuan_Newrelic', headers['newrelic']);
|
|
|
- magicJS.data.write('DIII_CaiLeYuan_apuid', headers['puid']);
|
|
|
let newToken = headers['token'];
|
|
|
let oldToken = magicJS.data.read('DIII_CaiLeYuan_Token', null);
|
|
|
if (newToken != oldToken) {
|