mrfrys-node-server/modules/qmining/views/veteranPw.ejs
2020-04-13 19:28:27 +02:00

150 lines
4.5 KiB
Text

<html>
<body bgcolor="#222426">
<head>
<title>Frylabs</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.6" />
<style>
a {
color: lightblue;
}
.center {
width: 440px;
height: 340px;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
max-width: 100%;
max-height: 100%;
overflow: auto;
text-align: center;
}
.text {
font-size: 18px;
color: white;
margin: 20px;
}
.title {
font-size: 50px;
font-weight: bold;
color: white;
}
.inputContainer {
width: 100%;
}
.showpwContainer {
color: white;
width: 40px;
cursor: pointer;
}
input[type=text], input[type=password] {
font-size: 20px;
color: #ffffff;
background-color: #181a1b;
width: 100%;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
border: 2px solid #333333;
text-align: center;
}
input[type=text], input[type=password]:focus {
border: 2px solid #000;
}
button {
width: 100px;
background-color: #9999ff;
border: none;
color: white;
padding: 16px 32px;
text-decoration: none;
margin: 4px 2px;
cursor: pointer;
}
#irc {
display: none;
}
</style>
</head>
<div class='center'>
<div class='title'>
Frylabs
</div>
<div id='text' class='text'>
Másold be ide régi kliens ID-d, és az alapján jelszót kapsz. Ezt csak egyszer teheted meg,
ezért a kapott jelszót tuti helyre írd le!
</div>
<div id='irc'>
<a class='ircLink' href='<%= devel? 'http' : 'https' %>://qmining.frylabs.net/irc?vetPwReqClick'>IRC</a>
</div>
<div id='form'>
<div class='inputContainer'>
<input type='text' id='cid' name='pw' value='<%= cid %>' autocomplete="off"/>
</div>
<input type='hidden' name='redirect' value='asd' autocomplete="off"/>
<button id='sendButton' onclick="GetVeteranPW(this)">Submit</button>
</div>
</div>
</body>
<script>
function HandleResp (resp) {
const textNode = document.getElementById('text')
document.getElementById('sendButton').innerText = 'Submit'
if (resp.result === 'success') {
document.getElementById('form').style.display = 'none'
textNode.innerText = 'Password:'
const pwDiv = document.createElement('div')
pwDiv.innerText = resp.pw
pwDiv.style.fontSize = '20px'
textNode.appendChild(pwDiv)
} else {
textNode.innerText = resp.msg
}
}
function HandleZeroStart () {
document.getElementById('form').style.display = 'none'
document.getElementById('irc').style.display = 'block'
document.getElementById('text').innerText = 'Client ID-d 0-val kezdődik. Ez azt jelenti hogy a jelszavasítás után telepítetted a scriptet, ezért nem vagy jogosult itt jelszót kérni. Ennek ellenére más felhasználóktól (akiknek már van jelszavuk) kérhetsz. Ha úgy gondolod valami nem stimmel:'
}
async function GetVeteranPW(button) {
button.innerText = '...'
const cid = document.getElementById('cid').value
if (cid[0] === '0') {
HandleZeroStart()
return
}
const rawResponse = await fetch('<%= devel? 'http' : 'https' %>://api.frylabs.net/getveteranpw', {
method: 'POST',
credentials: 'include',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
cid: cid
})
})
if (!rawResponse.ok) {
document.getElementById('text').innerText = 'Internal server error'
document.getElementById('sendButton').innerText = 'Submit'
}
try {
rawResponse.json()
.then((resp) => {
HandleResp(resp)
})
} catch (e) {
document.getElementById('text').innerText = 'Invalid data recieved from server'
document.getElementById('sendButton').innerText = 'Submit'
console.log(e)
}
}
</script>
</html>