211 lines
8.3 KiB
Plaintext
211 lines
8.3 KiB
Plaintext
@using Customize.ViewModels.Insynerger
|
|
@model InsynergerPreloginVM
|
|
|
|
@{
|
|
Layout = null;
|
|
}
|
|
|
|
<!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"
|
|
@*action="https://t-infactory.insynerger.com/auth/oauth/authorize?response_type=token&client_id=fffb99e0-e7f1-4281-ba72-1ec669f7c0b9&redirect_uri=https://qcarbon.insynerger.com/account/login"*@
|
|
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="@ViewBag.id" 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="@ViewBag.pd" @*onblur="passtomd()"*@
|
|
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>
|
|
@*using (Html.BeginForm())
|
|
{
|
|
@Html.AntiForgeryToken()
|
|
<div class="form-horizontal">
|
|
<div>
|
|
@Html.ValidationSummary(true)
|
|
</div>
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.CreatedTime, new { @class = "control-label docs-control-label col-xs-3" })
|
|
<div class="col-xs-9">
|
|
<div class="form-control">
|
|
@Model.CreatedTime
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}*@
|
|
</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: '@ViewBag.baseUrl/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: '@ViewBag.baseUrl/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: '@ViewBag.baseUrl/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;
|
|
}
|
|
validate('username cannot be empty');
|
|
</script>
|