demo20230512/Browser_Local/Insynerger.html
2023-05-12 10:20:28 +08:00

187 lines
7.7 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Insynerger</title>
</head>
<body>
<div class="col-md-12">
<h2>Insynerger</h2>
<hr />
<div class="col-md-1"></div>
<div class="docs-row col-md-10">
<table style="width:100%">
<tbody>
<tr>
<td width="100%">
<div class="loginContent">
<form id="loginForm"
action="https://t-infactory.insynerger.com/index.do"
method="post">
<input type="hidden" name="ecRequestToken" value="c2a1a091-d6de-47fe-92fb-799bba06fdf0" tabindex="0">
<table id="loginTable">
<thead>
<tr>
<th id="loginTableName" />
<th id="loginTableInput" />
</tr>
</thead>
<tbody>
<tr>
<td headers="loginTableName">
<label for="username"> 帳號 </label>
</td>
<td headers="loginTableInput">
<input type="text" name="username" id="username" maxlength="40" class="inputForm" style="width:70%"
value="weeerohsAdmin" tabindex="0">
</td>
</tr>
<tr>
<td headers="loginTableName">
<label for="username"> 密碼 </label>
</td>
<td headers="loginTableInput">
<input type="text" id="password" maxlength="20" class="inputForm"
autocomplete="off" style="width:70%" value="weeerohsAdmin"
onkeypress="if (event.keyCode == 13) {return false;}" tabindex="0">
<input type="hidden" name="password" id="realpassword" tabindex="0">
</td>
</tr>
<tr>
<td colspan="2" headers="loginTableName">
<a href="https://t-infactory.insynerger.com/getPW.do?ecRequestToken=c2a1a091-d6de-47fe-92fb-799bba06fdf0" tabindex="0" data-hasqtip="1" oldtitle="遺失密碼" title=""> 遺失密碼? </a>
</td>
</tr>
</tbody>
</table>
</form>
<table>
<tbody>
<tr>
<td colspan="2" headers="loginTableName">
<button class="logBtn" onclick="validate('username cannot be empty')" tabindex="0" style="cursor: pointer;"> 登入 </button>
</td>
</tr>
<tr>
<td colspan="2" headers="loginTableName">
<div class="error-message" style="margin-top: 10px;display:none;">
<span>登入失敗:</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
<script src="/Scripts/jquery-1.10.2.min.js"></script>
<script>
/**
* 驗證空白
*
* param value
* return true / false
*/
function validateEmpty(value) {
return value.replace(/\s/g, "") == "";
}
/**
* 登入檢查
* param msg
* returns {Boolean}
*/
function validate(msg) {
if (validateEmpty($("#username").val())) {
$(".error-message").show().html(msg);
$("#username").focus();
} else {
try {
oauthLogout();
} catch (e) { }
$("#loginForm").submit();
}
}
var isLoginSuccess = false;
function oauthLogout() {
//alert('oauth logout');
//$.ajaxSetup({ cache: false });
$.ajax({
async: false,
cache: true,
type: 'GET',
url: 'https://t-infactory.insynerger.com/auth/logout',
success: function (result) {
var resObj = $(result);
//console.log(resObj.find('#signinForm').length);
if (resObj.find('#signinForm').length > 0) {
oauthLogin(result);
isLoginSuccess = true;
}
}
});
if (!isLoginSuccess) {
$.ajax({
async: false,
cache: true,
type: 'GET',
url: 'https://t-infactory.insynerger.com/auth/index',
success: function (result) {
var resObj = $(result);
console.log('execute login again');
if (resObj.find('#signinForm').length > 0) {
oauthLogin(result);
isLoginSuccess = true;
}
}
});
}
}
function oauthLogin(loginInfo) {
var loginObj = $(loginInfo);
var status = false;
$.ajax({
async: false,
url: 'https://t-infactory.insynerger.com/auth/login',
type: 'POST',
cache: false,
contentType: 'application/x-www-form-urlencoded; charset=utf-8',
data: {
username: $('#loginForm').find('#username').val(),
password: $('#loginForm').find('#realpassword').val(),
_csrf: loginObj.find('input[name=_csrf]').val()
},
complete: function (xhr, textStatus) {
if (xhr.responseText.indexOf("{") == 0) {
var obj = jQuery.parseJSON(xhr.responseText);
if (obj.error === 'unauthorized') {
status = false;
} else {
status = true;
}
} else {
if ($(xhr.responseText).find('#signinForm').length > 0) {
status = false;
} else {
status = true;
}
}
}
});
return status;
}
</script>