portal端静态页会检查浏览器中存储的cookie来判断是否需要跳转到登录页面,这对前端调试很不友好

通过浏览器调试,找出关键点并禁用。

跳转到login.jsp,通过Chrome可以找出js的call stack

sendRedirect	@	10.100.2.113:3008/portal/frame/device_pc/script/compressed/152394938.js:17
ensureUserStateSecurity	@	10.100.2.113:3008/portal/tpl/webclassic/allcompressed/4193342375.js:3
checkPortletRefresh	@	10.100.2.113:3008/portal/tpl/webclassic/allcompressed/4193342375.js:3

http://10.100.2.113:3008/portal/tpl/webclassic/allcompressed/4193342375.js中找到checkPortletRefresh函数

4193342375.js代码压缩只是删除了EOL,而没有进行混淆,所以通过http://jsbeautifier.org/将代码格式化一下。

function checkPortletRefresh() {
    ensureUserStateSecurity();
    for (xa in refresh_circle) {
        var a = getContainer("#" + xa);
        if (!a.ModifiedSince || a.ModifiedSince < (new Date()).getTime() - refresh_circle[xa] * 1000) {
            a.doView();
            a.ModifiedSince = (new Date()).getTime();
        }
    }
}

function ensureUserStateSecurity() {
    try {
        var d = decodeURIComponent(getCookie("p_userId"));
        var b = getCookie("p_logoutflag");
        if ((d != null && d != "" && d != "annoyuser" && window.usercode.toLowerCase() != "annoyuser" && window.usercode.toLowerCase() != d.toLowerCase()) || "y" == b) {
            sendRedirect("/portal/app/mockapp/login.jsp?lrid=1");
        }
    } catch (a) {}
    try {
        var c = getCookie("p_forcelogoutflag");
        if (c != null && c == "1") {
            deleteCookie("p_forcelogoutflag", "/portal");
            showErrorDialog("由于当前用户在其他客户端强制登录,本客户端将退出工作台", function() {
                sendRedirect("/portal/pt/home/logout");
            }, "提示", "确定");
        }
    } catch (a) {}
}

复制真实登录NC的Cookie信息,然后使用js再创建出来就好了。

<script>
var COOKIE_STR = 'SERVERADDR=http://10.10.169.63:80; p_userId=tanruoyun; isMaxWindow=N; p_logoutflag=""; i18next=en; JSESSIONID=0000JgGIIzOPKtQv1Id9wrLo8OK:ncMem01; user_org=0001H210000000000IGL; pk_unit=0001H210000000000IGL; datasource=nc633g_SSC; userid=1001H21000000009ODLV; usercode=tanruoyun; TH_K1=webclassic; LA_K1=simpchn; token=00000158064a040e74616e72756f79756e331c35467e14cc96bbec4334ae077a786d67286b';
var cookie_arr = COOKIE_STR.split(';');
var i;
for (i in cookie_arr) {
  document.cookie = cookie_arr[i];
}
</script>