Commit deff63f5 by Kang Donghun

check login information in window.sessionStorage

parent 99c621b6
......@@ -5,7 +5,7 @@
height: 100vh;
width: 100vw;
display: block;
background: rgb(255,255,255,.5);
background: rgb(255, 255, 255);
background-position: center;
background-image: url("../img/loading.gif");
background-repeat: no-repeat;
......
......@@ -13,8 +13,34 @@
*/
var COMMON = {};
COMMON.hasErrorKey = 'AVW_HASERR';
CONSTANT.PAGE_NAME = {
DASHBOARD: 'dashboard',
OPERATION_LIST: 'workList',
REPORT_LIST: 'reportList',
REPORT_FORM: 'reportForm',
MESSAGE_DETAIL: 'pushMessageDetail',
MESSAGE_LIST: 'pushMessageList',
SEND_MESSAGE: 'sendMessage',
SETTING: 'accountSetting',
PICKUP: 'pickup',
PDF_PRINT: 'pdfPrint',
DEFAULT: 'index',
LOGIN: './login.html',
};
COMMON.loginCheckPageList = [CONSTANT.PAGE_NAME.DEFAULT, CONSTANT.PAGE_NAME.DASHBOARD, CONSTANT.PAGE_NAME.REPORT_LIST, CONSTANT.PAGE_NAME.REPORT_FORM,
CONSTANT.PAGE_NAME.MESSAGE_DETAIL, CONSTANT.PAGE_NAME.MESSAGE_LIST, CONSTANT.PAGE_NAME.SEND_MESSAGE, CONSTANT.PAGE_NAME.SETTING,
CONSTANT.PAGE_NAME.PICKUP, CONSTANT.PAGE_NAME.PDF_PRINT];
COMMON.hasErrorKey = 'AVW_HASERR';
$(document).ready(function() {
if (location.href.includes(COMMON.loginCheckPageList)) {
if (!COMMON.checkLogin(CONSTANT.PAGE_NAME.LOGIN)){
return;
}
}
})
/**
* page transition without outputting a warning message
* @param {*} url
......@@ -557,13 +583,17 @@ var UserSession = function () {
*/
UserSession.prototype.init = function (option) {
this.available = false;
console.log("kdh check userSession init option : " + option);
if (option == 'restore') {
var value = null;
try {
value = this._get('init');
console.log("kdh check userSession init value : " + value);
} catch (e) {
value = null;
console.log("kdh check userSession init catch : " + e);
} finally {
console.log("kdh check userSession init final : " + value);
if (value) {
this.available = true;
}
......@@ -600,6 +630,7 @@ UserSession.prototype.set = function (key, value) {
* @returns
*/
UserSession.prototype.get = function (key) {
console.log("kdh check userSession get");
var value = null;
if (this.available) {
value = this._get(key);
......@@ -745,13 +776,16 @@ COMMON.setErrorState = function () {
/* get user session object */
COMMON.userSession = function () {
if (!COMMON.userSessionObj) {
console.log("kdh check userSession : COMMON.userSessionObj null");
var obj = new UserSession();
obj.init('restore');
if (obj.available) {
console.log("kdh check userSession : COMMON.userSessionObj available");
COMMON.userSessionObj = obj;
return COMMON.userSessionObj;
} else {
return null;
console.log("kdh check userSession : COMMON.userSessionObj unavailable");
return CO;
}
}
return COMMON.userSessionObj;
......@@ -793,6 +827,7 @@ var SessionStorageUtils = {
}
},
get: function (strKey) {
console.log("kdh check SessionStorageUtils get : " + strKey);
return COMMON.userSession().get(strKey);
},
set: function (strKey, objValue) {
......@@ -962,6 +997,56 @@ COMMON.currentTime = function () {
return Date.now();
};
/**
* check login information in window.sessionStorage
*
* @returns boolean
*/
COMMON.checkLogin = function (option) {
var userSession = COMMON.userSession();
if(!userSession) {
/* エラー画面を表示 */
var tags = '<div id="avw-auth-error">' +
'<div style="display:table; width:100%; height:100%;">' +
'<div style="display:table-cell; text-align:center; vertical-align:middle;">' +
'<p><h4>Authentication error</h4>Please use it after login.</p>' +
'<div><button id="avw-unauth-ok">OK</button></div>' +
'</div></div></div>';
$('body').prepend(tags);
$('#avw-auth-error').css({
'opacity': 1,
'position': 'fixed',
'top': '0',
'left': '0',
'width': $(window).width(),
'height': $(window).height(),
'zIndex': '10000'
});
// resize error page
$(window).resize(function() {
$('#avw-auth-error').css( {
'width': $(window).width(),
'height': $(window).height()
});
});
var returnPage;
if(option) {
returnPage = option
} else {
var sysSetting = COMMON.sysSetting();
returnPage = sysSetting.loginPage;
}
/* ログイン画面に戻る */
$('#avw-unauth-ok').click(function() {
window.location = returnPage;
});
return false;
}
return true;
}
/*
* Operations for session storage [ end ]
*/
......
......@@ -13,7 +13,7 @@
"pushPageCount" : 5,
"pushTimePeriod" : 60,
"debug" : true,
"loginPage" : "index.html",
"loginPage" : "login.html",
"anonymousLoginFlg" : false,
"anonymousLoginPath" : "test",
"anonymousLoginId" : "nologin",
......
......@@ -42,20 +42,7 @@
<div id="includedHeader"></div>
<!-- title -->
<div id="main-ttl">
<div class="container-wrap">
<!-- breadcrumb -->
<nav aria-label="breadcrumb">
<ol class="breadcrumb px-0 mb-0">
<li class="breadcrumb-item"><a href="task-list.html" class="text-decoration-none text-underline">作業一覧</a></li>
<li class="breadcrumb-item"><a href="report-list.html" class="text-decoration-none text-underline">報告一覧</a></li>
<li class="breadcrumb-item active" aria-current="page"><span>pdf出力</span></li>
</ol>
</nav>
<!-- title -->
<h1 class="fs-14 font-weight-bold pt-sm-4 pt-2 pb-3 mb-0">pdf出力</h1>
</div>
</div>
<div id="includedMainTitle"></div>
<!-- ↓↓↓ ここから共通HTML ↓↓↓ -->
<div class="container-wrap mb-5" id="pdfPrintDiv" ></div>
......
......@@ -35,7 +35,7 @@ SETTINGS.getToken = function () {
if (data.errorMessage) {
COMMON.displayAlert(data.errorMessage);
} else {
COMMON.displayAlert('msgPwdChangeOK');
COMMON.displayAlert('msgPwdChangeNG');
}
});
};
......
......@@ -32,7 +32,7 @@ modify_api()
"pushPageCount" : 5,
"pushTimePeriod" : 60,
"debug" : false,
"loginPage" : "index.html",
"loginPage" : "login.html",
"anonymousLoginFlg" : false,
"anonymousLoginPath" : "test",
"anonymousLoginId" : "nologin",
......
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