mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Removed veteranpw api and page
This commit is contained in:
parent
0654a36d21
commit
81577ad621
4 changed files with 1 additions and 259 deletions
|
@ -68,7 +68,6 @@ const recievedQuestionFile = 'stats/recievedQuestions'
|
|||
|
||||
// other constants
|
||||
const line = '====================================================' // lol
|
||||
const maxVeteranPwGetCount = 10
|
||||
const addPWPerDay = 3 // every x day a user can give a pw
|
||||
const maxPWCount = 6 // maximum pw give opportunities a user can have at once
|
||||
const addPWCount = 1 // how many pw gen opportunities to add each time
|
||||
|
@ -143,7 +142,6 @@ function GetApp(): ModuleType {
|
|||
exceptions: [
|
||||
'/favicon.ico',
|
||||
'/login',
|
||||
'/getveteranpw',
|
||||
'/postfeedbackfile',
|
||||
'/postfeedback',
|
||||
'/fosuploader',
|
||||
|
@ -585,102 +583,6 @@ function GetApp(): ModuleType {
|
|||
})
|
||||
})
|
||||
|
||||
app.post('/getveteranpw', function(req: Request, res: any) {
|
||||
logger.LogReq(req)
|
||||
const ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress
|
||||
const tries = dbtools.Select(userDB, 'veteranPWRequests', {
|
||||
ip: ip,
|
||||
})[0]
|
||||
|
||||
if (tries) {
|
||||
if (tries.count > maxVeteranPwGetCount) {
|
||||
res.json({
|
||||
result: 'error',
|
||||
msg: 'Too many tries from this IP',
|
||||
})
|
||||
logger.Log(
|
||||
`Too many veteran PW requests from ${ip}!`,
|
||||
logger.GetColor('cyan')
|
||||
)
|
||||
return
|
||||
} else {
|
||||
dbtools.Update(
|
||||
userDB,
|
||||
'veteranPWRequests',
|
||||
{
|
||||
count: tries.count + 1,
|
||||
lastDate: utils.GetDateString(),
|
||||
},
|
||||
{
|
||||
id: tries.id,
|
||||
}
|
||||
)
|
||||
}
|
||||
} else {
|
||||
dbtools.Insert(userDB, 'veteranPWRequests', {
|
||||
ip: ip,
|
||||
lastDate: utils.GetDateString(),
|
||||
})
|
||||
}
|
||||
|
||||
const oldUserID = req.body.cid
|
||||
|
||||
if (!oldUserID) {
|
||||
res.json({
|
||||
result: 'error',
|
||||
msg: 'No Client ID recieved',
|
||||
})
|
||||
logger.Log(`No client ID recieved`, logger.GetColor('cyan'))
|
||||
return
|
||||
}
|
||||
|
||||
const user: User = dbtools.Select(userDB, 'users', {
|
||||
oldCID: oldUserID,
|
||||
})[0]
|
||||
|
||||
if (user) {
|
||||
if (user.pwGotFromCID === 0) {
|
||||
logger.Log(
|
||||
`Sent password to veteran user #${user.id}`,
|
||||
logger.GetColor('cyan')
|
||||
)
|
||||
dbtools.Update(
|
||||
userDB,
|
||||
'users',
|
||||
{
|
||||
pwGotFromCID: 1,
|
||||
},
|
||||
{
|
||||
id: user.id,
|
||||
}
|
||||
)
|
||||
|
||||
res.json({
|
||||
result: 'success',
|
||||
pw: user.pw,
|
||||
})
|
||||
} else {
|
||||
logger.Log(
|
||||
`Veteran user #${user.id} already requested password`,
|
||||
logger.GetColor('cyan')
|
||||
)
|
||||
res.json({
|
||||
result: 'error',
|
||||
msg: 'Password already requested',
|
||||
})
|
||||
}
|
||||
} else {
|
||||
logger.Log(
|
||||
`Invalid password request with CID: ${oldUserID}`,
|
||||
logger.GetColor('cyan')
|
||||
)
|
||||
res.json({
|
||||
result: 'error',
|
||||
msg: 'No such Client ID',
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
app.post('/login', (req: Request, res: any) => {
|
||||
logger.LogReq(req)
|
||||
const pw = req.body.pw
|
||||
|
|
|
@ -58,9 +58,7 @@ function GetApp(): ModuleType {
|
|||
'/thanks',
|
||||
'/thanks.html',
|
||||
'/img/thanks.gif',
|
||||
'/install',
|
||||
'/favicon.ico',
|
||||
'/getVeteranPw',
|
||||
'/moodle-test-userscript/stable.user.js',
|
||||
'/irc',
|
||||
'/donate',
|
||||
|
@ -221,14 +219,6 @@ function GetApp(): ModuleType {
|
|||
logger.LogReq(req)
|
||||
})
|
||||
|
||||
app.get('/getVeteranPw', function(req: Request, res) {
|
||||
res.render('veteranPw', {
|
||||
cid: req.query.cid || '',
|
||||
devel: process.env.NS_DEVEL,
|
||||
})
|
||||
logger.LogReq(req)
|
||||
})
|
||||
|
||||
app.get('*', function(req: Request, res) {
|
||||
res.status(404).render('404')
|
||||
})
|
||||
|
|
|
@ -1,150 +0,0 @@
|
|||
|
||||
<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>
|
|
@ -1 +1 @@
|
|||
Subproject commit e935de7e7896ca5207de84672ecdaa89a003827a
|
||||
Subproject commit bc776b3307c975f826afb1338874330924d601ba
|
Loading…
Add table
Add a link
Reference in a new issue