Created
July 18, 2019 16:29
-
-
Save ruan65/d59fdcc1d024a7d5fb51278faab44fef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>TradeIt oAuth Login</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no, minimal-ui"/> | |
<meta name="apple-mobile-web-app-capable" content="yes"/> | |
<style> | |
html { | |
font-family: sans-serif; | |
-ms-text-size-adjust: 100%; | |
-webkit-text-size-adjust: 100%; | |
} | |
body { | |
margin: 0; | |
background-color: #EAEDF3; | |
} | |
main, header { | |
display: block; | |
} | |
a { | |
background-color: transparent; | |
} | |
button::-moz-focus-inner, | |
input::-moz-focus-inner { | |
border: 0; | |
padding: 0; | |
} | |
*, *:after, *:before { | |
box-sizing: border-box; | |
-webkit-font-smoothing: subpixel-antialiased; | |
} | |
input { | |
outline: 0; | |
-webkit-user-select: text; | |
} | |
button { | |
border: none; | |
color: white; | |
outline: 0; | |
padding: 15px 32px; | |
text-align: center; | |
text-decoration: none; | |
} | |
body { | |
height: 100%; | |
min-height: 350px; | |
position: absolute; | |
width: 100%; | |
} | |
h1 { | |
font-size: 22px; | |
margin: 25px 0; | |
padding-top: 60px; | |
text-align: center; | |
color: #5281C8; | |
} | |
h2 { | |
font-size: 14px; | |
margin: 20px; | |
text-align: center; | |
} | |
main { | |
position: relative; | |
background-color: #ffffff; | |
margin: 0 20px; | |
padding-bottom: 100px; | |
border-bottom: 4px solid #003358; | |
} | |
input { | |
border: none; | |
border-bottom: 2px solid #DEDEDE; | |
font-size: 18px; | |
left: 20%; | |
margin-bottom: 15px; | |
padding: 15px 5px; | |
position: relative; | |
text-align: left; | |
width: 61%; | |
} | |
#loginUser { | |
background: url(https://ems.tradingticket.com/assets/icon-user-input.png) no-repeat scroll 2px 12px; | |
background-size: 25px 25px; | |
padding-left: 40px; | |
} | |
#loginPwd { | |
background: url(https://ems.tradingticket.com/assets/icon-lock-input.png) no-repeat scroll 2px 12px; | |
background-size: 25px 25px; | |
padding-left: 40px; | |
} | |
button { | |
background-color: #5281C8; | |
border: none; | |
border-radius: 5px; | |
color: #FFF; | |
cursor: pointer; | |
display: block; | |
font-size: 18px; | |
margin: 22px auto; | |
padding: 15px 80px; | |
position: relative; | |
} | |
footer { | |
bottom: 10px; | |
font-size: 14px; | |
left: 0; | |
position: absolute; | |
text-align: center; | |
width: 100%; | |
} | |
footer p { | |
color: #A9A9AC; | |
line-height: 30px; | |
} | |
footer .TermAndConditions p { | |
color: #5281EF; | |
} | |
footer .footerLogo { | |
height: 13px; | |
width: 85px; | |
margin: 0 3px; | |
} | |
a, a:link, a:visited, a:hover, a:active { | |
color: #5281EF; | |
text-decoration: none; | |
cursor: pointer; | |
} | |
#Loading { | |
bottom: 0; | |
left: 0; | |
position: absolute; | |
right: 0; | |
top: 0; | |
z-index: 10; | |
} | |
#Loading img { | |
display: block; | |
width: 108px; | |
left: 50%; | |
position: absolute; | |
top: 50%; | |
margin: -54px 0 0 -54px; | |
} | |
#alertText, #alertSecurityQuestionText, #SecurityQuestionForm, #Loading { | |
display: none; | |
} | |
#alertText, #alertSecurityQuestionText { | |
font-size: 17px; | |
margin-bottom: 10px; | |
text-align: center; | |
color: #CC5151; | |
padding: 0px 25px; | |
} | |
div.security a #nortonSeal { | |
max-width: 100%; | |
height: 58px; | |
} | |
div.security a #trusteSeal { | |
max-width: 100%; | |
height: auto; | |
} | |
@media (max-height: 720px) { | |
main { | |
position: relative; | |
background-color: #ffffff; | |
margin: 0 20px; | |
padding-bottom: 20px; | |
border-bottom: 3px solid #003358; | |
} | |
} | |
@media (max-height: 645px) { | |
div.security a #nortonSeal { | |
max-width: 100%; | |
height: 45px; | |
} | |
div.security a #trusteSeal { | |
max-width: 100%; | |
height: 35px; | |
} | |
h1 { | |
font-size: 19px; | |
margin: 10px 0; | |
} | |
input { | |
font-size: 15px; | |
margin-bottom: 10px; | |
padding: 6px 5px; | |
} | |
button { | |
background-color: #5281C8; | |
border: none; | |
border-radius: 5px; | |
color: #FFF; | |
cursor: pointer; | |
display: block; | |
font-size: 18px; | |
margin: 19px auto; | |
padding: 8px 80px; | |
position: relative; | |
} | |
footer { | |
top: 28%; | |
position: relative; | |
font-size: 12px; | |
} | |
footer p { | |
margin: 0 5px; | |
line-height: 20px; | |
} | |
#loginUser { | |
background: url(https://ems.tradingticket.com/assets/icon-user-input.png) no-repeat scroll 2px 2px; | |
background-size: 20px 20px; | |
padding-left: 40px; | |
} | |
#loginPwd { | |
background: url(https://ems.tradingticket.com/assets/icon-lock-input.png) no-repeat scroll 2px 2px; | |
background-size: 20px 20px; | |
padding-left: 40px; | |
} | |
#alertText, #alertSecurityQuestionText { | |
font-size: 13px; | |
margin-bottom: 6px; | |
padding: 0px 33px; | |
} | |
} | |
@media (max-height: 615px) { | |
footer { | |
top: 20px; | |
font-size: 12px; | |
left: 0; | |
position: relative; | |
} | |
} | |
@media (max-width: 500px) { | |
#loginUser { | |
font-size: 14px; | |
} | |
#loginPwd { | |
font-size: 14px; | |
} | |
} | |
@media (max-width: 420px) { | |
footer { | |
font-size: 12px; | |
width: 100%; | |
} | |
button { | |
width: 76%; | |
border-radius: 5px; | |
} | |
input { | |
width: 76%; | |
left: 12%; | |
} | |
div.security a #nortonSeal { | |
max-width: 100%; | |
height: 45px; | |
} | |
div.security a #trusteSeal { | |
max-width: 100%; | |
height: 35px; | |
} | |
} | |
@media (max-width: 370px) { | |
input { | |
font-size: 14px; | |
} | |
button { | |
font-size: 10px; | |
} | |
} | |
</style> | |
</head> | |
<body> | |
<main> | |
<h1>Link Dummy Broker</h1> | |
<div id="alertText">alert!</div> | |
<div id="alertSecurityQuestionText">alert!</div> | |
<div id="LoginForm"> | |
<input class="credFields" id="loginUser" type="text" name="id" placeholder="Dummy Broker Username" | |
autocorrect="off" autocapitalize="none"/> | |
<input class="credFields" id="loginPwd" type="password" name="password" placeholder="Dummy Broker Password" | |
autocorrect="off" autocapitalize="none"/> | |
<button type="submit">Sign In</button> | |
</div> | |
<div id="SecurityQuestionForm"> | |
<input class="credFields" id="securityAnswer" type="password" name="securityAnswer" placeholder="Dummy Broker Security answer" | |
autocorrect="off" autocapitalize="none"/> | |
<button type="submit">Submit</button> | |
</div> | |
<div id="Loading"> | |
<div class="overlay"></div> | |
<img src="/assets/loading-c16f1576a90bd0d292f8a1a26c24f4a9.gif" /> | |
</div> | |
</main> | |
<footer> | |
<p>All of your login information is always protected using the<br/>same 256-bit encryption that banks and brokers use. | |
</p> | |
<div class="TermAndConditions"> | |
<p> | |
<a id="learnMoreHref" href="">Powered by <span> | |
<img src="https://ems.tradingticket.com/assets/logo.png" alt="TradeIt" class="footerLogo" /> | |
</span></a> | |
<a id="termsHref" href="">Terms & Conditions</a> | |
</p> | |
</div> | |
<div class="security"> | |
<script type="text/javascript" | |
src="https://seal.websecurity.norton.com/getseal?host_name=www.tradingticket.com&size=XS&use_flash=NO&use_transparent=YES&lang=en"></script><a | |
title="Click to Verify - This site chose Symantec SSL for secure e-commerce and confidential communications." | |
href="javascript:try{vrsn_splash()}catch (e){}" tabIndex="-1"></a> | |
<a href="//privacy.truste.com/privacy-seal/validation?rid=7a4b6f44-9e3c-40c9-a79a-458661bc5e4b" | |
title="TRUSTe Privacy Certification" target="_blank"><img id="trusteSeal" | |
src="//privacy-policy.truste.com/privacy-seal/seal?rid=7a4b6f44-9e3c-40c9-a79a-458661bc5e4b" | |
alt="TRUSTe Privacy Certification"/></a> | |
</div> | |
</footer> | |
<script | |
src="https://code.jquery.com/jquery-2.2.4.min.js" | |
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" | |
crossorigin="anonymous"></script> | |
<script type="text/javascript"> | |
$(function () { | |
var srv = new Date().getTime(); | |
var apiURL = "https://ems.qa.tradingticket.com/api/v1/"; | |
var broker = "Dummy"; | |
var oAuthTemp = "4b133e0b-388c-438f-812f-8ba20673cfe5"; | |
var $loginForm = $('#LoginForm'); | |
var $securityQuestionForm = $('#SecurityQuestionForm'); | |
var $loading = $('#Loading'); | |
var $alert = $('#alertText'); | |
var $alertSecurityQuestion = $('#alertSecurityQuestionText'); | |
var token; | |
//enter user to hit sign in with Enter btn on keyboard when credential fields are filled | |
$('.credFields').keypress(function (e) { | |
if (e.which == 13) { | |
if ($('#alertSecurityQuestionText').val() == "" && $('input[name="id"]').val() != "" && $('input[name="password"]').val() != "") { | |
linkUser($('input[name="id"]').val(), $('input[name="password"]').val()); | |
} | |
if ($('input[name="securityAnswer"]').val() != "") { | |
answerSecurityQuestion( | |
$('input[name="id"]', $loginForm[0]).val(), | |
$('input[name="password"]', $loginForm[0]).val(), | |
$('input[name="securityAnswer"]').val(), | |
token | |
); | |
} | |
} | |
}); | |
$("#learnMoreHref").attr("href", 'https://www.trade.it/oAuth-learnMore?hideHeader=true&hideFooter=true&oAuthURL=' + document.URL); | |
$("#termsHref").attr("href", 'https://www.trade.it/oAuth-terms?hideHeader=true&hideFooter=true&oAuthURL=' + document.URL); | |
var parseResult = function (result) { | |
result = result || {}; | |
var shortMessage = result.shortMessage; | |
var longMessages = result.longMessages; | |
token = (result.token != undefined && result.token != "") ? result.token : token; | |
$alert.empty(); | |
$alertSecurityQuestion.empty(); | |
if (result.status == 'ERROR') { | |
if(longMessages.join('').indexOf('temporary token is invalid') >= 0) { | |
longMessages = 'Please return to the app and try to link again.'; | |
} | |
$alert.html(shortMessage + '<br />' + longMessages); | |
$alert.show(); | |
$loading.hide(); | |
} else if(result.status == 'INFORMATION_NEEDED') { | |
$loginForm.hide(); | |
$alertSecurityQuestion.html(result.securityQuestion); | |
$alertSecurityQuestion.show(); | |
$securityQuestionForm.show(); | |
$loading.hide(); | |
} else if (result.status == 'SUCCESS') { | |
$alert.empty(); | |
$alert.hide(); | |
if (window.opener) { | |
window.opener.postMessage(JSON.stringify(result), "*"); | |
window.close(); | |
} else { | |
window.parent.postMessage(JSON.stringify(result), "*"); | |
} | |
$loading.hide(); | |
} else { | |
//TODO: handle failed request | |
} | |
}; | |
var linkUser = function (id, password, token) { | |
var data = { | |
id: id, | |
password: password, | |
broker: broker, | |
oAuthTempToken: oAuthTemp, | |
srv: srv, | |
oauthPopUpVersion: "1.1" | |
}; | |
if (token != undefined && token != "") { | |
data["sessionToken"] = token | |
} | |
sendRequest(data, apiURL + 'user/oAuthLinkWithTempToken'); | |
}; | |
var answerSecurityQuestion = function (id, password, securityAnswer, token) { | |
var data = { | |
id: id, | |
password: password, | |
broker: broker, | |
oAuthTempToken: oAuthTemp, | |
token: token, | |
securityAnswer: securityAnswer, | |
srv: srv, | |
oauthPopUpVersion: "1.1" | |
}; | |
sendRequest(data, apiURL + 'user/answerSecurityQuestionForLinking'); | |
}; | |
var sendRequest = function (data, url) { | |
$loading.show(); | |
$.ajax({ | |
url: url, | |
data: data, | |
dataType: "json", | |
method: 'POST', | |
error: function () { | |
parseResult({ | |
status: 'ERROR', | |
shortMessage: 'Could Not Login', | |
longMessages: ["We're having trouble connecting, please try again later."] | |
}); | |
}, | |
success: parseResult | |
}); | |
}; | |
$('button', $loginForm[0]).on('click', function () { | |
if ($('input[name="id"]').val() != "" && $('input[name="password"]').val() != "") { | |
linkUser($('input[name="id"]', $loginForm[0]).val(), $('input[name="password"]', $loginForm[0]).val(), token); | |
} | |
}); | |
$('button', $securityQuestionForm[0]).on('click', function () { | |
if ($('input[name="securityAnswer"]').val() != "") { | |
answerSecurityQuestion( | |
$('input[name="id"]', $loginForm[0]).val(), | |
$('input[name="password"]', $loginForm[0]).val(), | |
$('input[name="securityAnswer"]').val(), | |
token | |
); | |
} | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment