mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Exit signal handling polish, login page info added
This commit is contained in:
parent
4f030ad27c
commit
88d487568c
6 changed files with 21 additions and 69 deletions
|
@ -46,8 +46,8 @@ const dailyDataCountFile = 'stats/dailyDataCount'
|
||||||
const usersDbBackupPath = 'data/dbs/backup'
|
const usersDbBackupPath = 'data/dbs/backup'
|
||||||
|
|
||||||
const maxVeteranPwGetCount = 10
|
const maxVeteranPwGetCount = 10
|
||||||
const addPWPerDay = 3 // every x day a user can give a pw
|
const addPWPerDay = 1 // every x day a user can give a pw
|
||||||
const maxPWCount = 2 // maximum pw give opportunities a user can have at once
|
const maxPWCount = 4 // maximum pw give opportunities a user can have at once
|
||||||
const daysAfterUserGetsPWs = 2 // days after user gets pw-s
|
const daysAfterUserGetsPWs = 2 // days after user gets pw-s
|
||||||
|
|
||||||
let userDB
|
let userDB
|
||||||
|
@ -229,6 +229,7 @@ function GetApp () {
|
||||||
app.post('/login', (req, res) => {
|
app.post('/login', (req, res) => {
|
||||||
logger.LogReq(req)
|
logger.LogReq(req)
|
||||||
const pw = req.body.pw || false
|
const pw = req.body.pw || false
|
||||||
|
const cid = req.body.cid
|
||||||
const isScript = req.body.script
|
const isScript = req.body.script
|
||||||
const ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress
|
const ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress
|
||||||
const user = dbtools.Select(userDB, 'users', {
|
const user = dbtools.Select(userDB, 'users', {
|
||||||
|
@ -286,7 +287,7 @@ function GetApp () {
|
||||||
})
|
})
|
||||||
logger.Log(`Successfull login to ${isScript ? 'script' : 'website'} with user ID: #${user.id}`, logger.GetColor('cyan'))
|
logger.Log(`Successfull login to ${isScript ? 'script' : 'website'} with user ID: #${user.id}`, logger.GetColor('cyan'))
|
||||||
} else {
|
} else {
|
||||||
logger.Log(`Login attempt with invalid pw: ${pw} to ${isScript ? 'script' : 'website'}`, logger.GetColor('cyan'))
|
logger.Log(`Login attempt with invalid pw: ${pw} to ${isScript ? 'script' : 'website'}${cid ? ', CID:' + cid : ''}`, logger.GetColor('cyan'))
|
||||||
res.json({
|
res.json({
|
||||||
result: 'error',
|
result: 'error',
|
||||||
msg: 'Invalid password'
|
msg: 'Invalid password'
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 179aa6ebfab2a85c59a251d7bf08988076a51732
|
Subproject commit 25b9f72093c490a11580320b152f8eef21d63da2
|
|
@ -1 +1 @@
|
||||||
Subproject commit c93cf0e02883ac545086afb3c22f71c6d1cdf297
|
Subproject commit 0e8f6cd2d90ecae8d25f88729a5d3c23ce9d715b
|
|
@ -1 +1 @@
|
||||||
Subproject commit 7dc12dbfa0343138237518435224f5ae34b3cff6
|
Subproject commit a25e64189e050bcde8408bef0628d792e10b8b67
|
|
@ -64,10 +64,7 @@ try {
|
||||||
|
|
||||||
// Setting up exits
|
// Setting up exits
|
||||||
// process.on('exit', () => exit('exit'))
|
// process.on('exit', () => exit('exit'))
|
||||||
// process.on('exit', () => exit('exit'))
|
|
||||||
process.on('SIGINT', () => exit('SIGINT'))
|
process.on('SIGINT', () => exit('SIGINT'))
|
||||||
process.on('SIGINT', () => exit('SIGINT'))
|
|
||||||
process.on('SIGTERM', () => exit('SIGTERM'))
|
|
||||||
process.on('SIGTERM', () => exit('SIGTERM'))
|
process.on('SIGTERM', () => exit('SIGTERM'))
|
||||||
|
|
||||||
function exit (reason) {
|
function exit (reason) {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
.center {
|
.center {
|
||||||
width: 340px;
|
width: 380px;
|
||||||
height: 340px;
|
height: 340px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
margin: auto;
|
margin: auto;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
overflow: auto;
|
overflow: none;
|
||||||
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
@ -88,73 +88,26 @@
|
||||||
Frylabs
|
Frylabs
|
||||||
</div>
|
</div>
|
||||||
<div id='text' class='text'>
|
<div id='text' class='text'>
|
||||||
</div>
|
Ha régi felhasználó vagy akkori <a
|
||||||
<div id='feedback'>
|
href='https://greasyfork.org/en/scripts/38999-moodle-elearning-kmooc-test-help')>frissítsd
|
||||||
<textarea placeholder='Feedback' id='feedbackTextArea'></textarea>
|
a scriptet 2.0.1.*-ra</a>, és automatikusan kapsz jelszót. Bármi nem megy: <a
|
||||||
<div class='ircLinkContainer' >
|
href='https://qmining.frylabs.net/irc?loginClick'>IRC</a>
|
||||||
<a class='ircLink' href='https://qmining.frylabs.net/irc?loginClick'>IRC</a>
|
|
||||||
</div>
|
|
||||||
<button id='sendFeedbackButton' onclick="SendFeedback(this)">Submit</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div id='form'>
|
<div id='form'>
|
||||||
<div class='inputContainer'>
|
<div class='inputContainer'>
|
||||||
<input type='password' id='pw' name='pw' autocomplete="off"/>
|
<input type='text' id='pw' name='pw' autocomplete="off"/>
|
||||||
<input type='hidden' id='cid' name='pw' autocomplete="off"/>
|
<input type='hidden' id='cid' name='pw' autocomplete="off"/>
|
||||||
</div>
|
</div>
|
||||||
<div class='ircLinkContainer' >
|
<div class='ircLinkContainer' >
|
||||||
<a class='ircLink' onclick='ShowFeedback()'>Contact</a>
|
<a class='ircLink' href='https://qmining.frylabs.net/irc?loginClick'>IRC</a>
|
||||||
</div>
|
</div>
|
||||||
<button id='sendButton' onclick="Login(this)">Submit</button>
|
<button id='sendButton' onclick="Login(this)">Login</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
function HandleFeedbackResp (resp) {
|
|
||||||
document.getElementById('sendButton').innerText = 'Submit'
|
|
||||||
const textNode = document.getElementById('text')
|
|
||||||
const feedback = document.getElementById('feedback').style.display = "none";
|
|
||||||
if (resp.success) {
|
|
||||||
textNode.innerText = 'Visszajelzés elküldve'
|
|
||||||
} else {
|
|
||||||
textNode.innerText = 'Szerver oldali hiba :c'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async function SendFeedback (button) {
|
|
||||||
const feedback = document.getElementById('feedbackTextArea').value
|
|
||||||
button.innerText = '...'
|
|
||||||
const rawResponse = await fetch('https://api.frylabs.net/postfeedback', {
|
|
||||||
method: 'POST',
|
|
||||||
credentials: 'include',
|
|
||||||
headers: {
|
|
||||||
'Accept': 'application/json',
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
description: feedback,
|
|
||||||
fromLogin: true
|
|
||||||
})
|
|
||||||
})
|
|
||||||
if (!rawResponse.ok) {
|
|
||||||
document.getElementById('text').innerText = 'Internal server error'
|
|
||||||
button.innerText = 'Submit'
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
rawResponse.json()
|
|
||||||
.then((resp) => {
|
|
||||||
HandleFeedbackResp(resp)
|
|
||||||
})
|
|
||||||
} catch (e) {
|
|
||||||
document.getElementById('text').innerText = 'Invalid data recieved from server'
|
|
||||||
button.innerText = 'Submit'
|
|
||||||
console.log(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function ShowFeedback () {
|
|
||||||
const form = document.getElementById('form').style.display = "none";
|
|
||||||
const feedback = document.getElementById('feedback').style.display = "block";
|
|
||||||
}
|
|
||||||
function HandleResp (resp) {
|
function HandleResp (resp) {
|
||||||
document.getElementById('sendButton').innerText = 'Submit'
|
document.getElementById('sendButton').innerText = 'Login'
|
||||||
const textNode = document.getElementById('text')
|
const textNode = document.getElementById('text')
|
||||||
if (resp.result === 'success') {
|
if (resp.result === 'success') {
|
||||||
location.reload()
|
location.reload()
|
||||||
|
@ -173,12 +126,13 @@
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
pw: document.getElementById('pw').value
|
pw: document.getElementById('pw').value,
|
||||||
|
cid: document.getElementById('cid').value
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
if (!rawResponse.ok) {
|
if (!rawResponse.ok) {
|
||||||
document.getElementById('text').innerText = 'Internal server error'
|
document.getElementById('text').innerText = 'Internal server error'
|
||||||
button.innerText = 'Submit'
|
button.innerText = 'Login'
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
rawResponse.json()
|
rawResponse.json()
|
||||||
|
@ -187,7 +141,7 @@
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
document.getElementById('text').innerText = 'Invalid data recieved from server'
|
document.getElementById('text').innerText = 'Invalid data recieved from server'
|
||||||
button.innerText = 'Submit'
|
button.innerText = 'Login'
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue