diff --git a/modules/api/api.js b/modules/api/api.js index e4c6032..0bbf469 100644 --- a/modules/api/api.js +++ b/modules/api/api.js @@ -45,7 +45,7 @@ const dataEditsLog = 'stats/dataEdits' const dailyDataCountFile = 'stats/dailyDataCount' const usersDbBackupPath = 'data/dbs/backup' -const maxVeteranPwGetCount = 5 +const maxVeteranPwGetCount = 10 const addPWPerDay = 3 // every x day a user can give a pw const maxPWCount = 2 // maximum pw give opportunities a user can have at once const daysAfterUserGetsPWs = 2 // days after user gets pw-s @@ -151,7 +151,6 @@ function GetApp () { app.post('/getveteranpw', function (req, res) { logger.LogReq(req) const ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress - const tries = dbtools.Select(userDB, 'veteranPWRequests', { ip: ip })[0] @@ -160,7 +159,7 @@ function GetApp () { if (tries.count > maxVeteranPwGetCount) { res.json({ result: 'error', - msg: 'Too many tries' + msg: 'Too many tries from this IP' }) logger.Log(`Too many veteran PW requests from ${ip}!`, logger.GetColor('cyan')) return @@ -180,10 +179,11 @@ function GetApp () { } const oldUserID = req.body.cid + if (!oldUserID) { res.json({ result: 'error', - msg: 'No CID recieved' + msg: 'No Client ID recieved' }) logger.Log(`No client ID recieved`, logger.GetColor('cyan')) return @@ -210,14 +210,14 @@ function GetApp () { logger.Log(`Veteran user #${user.id} already requested password`, logger.GetColor('cyan')) res.json({ result: 'error', - msg: 'Password already requested once' + msg: 'Password already requested' }) } } else { logger.Log(`Invalid password request with CID: ${oldUserID}`, logger.GetColor('cyan')) res.json({ result: 'error', - msg: 'no such CID' + msg: 'No such Client ID' }) } }) @@ -225,7 +225,6 @@ function GetApp () { app.post('/login', (req, res) => { logger.LogReq(req) const pw = req.body.pw - const redirectTo = req.body.redirect const ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress const user = dbtools.Select(userDB, 'users', { pw: pw @@ -269,24 +268,17 @@ function GetApp () { sameSite: 'none' }) - if (redirectTo) { - res.redirect(redirectTo) - } else { - res.json({ - result: 'success', - msg: 'you are now logged in' - }) - } + res.json({ + result: 'success', + msg: 'you are now logged in' + }) logger.Log(`Successfull login with user ID: #${user.id}`, logger.GetColor('cyan')) } else { logger.Log(`Login attempt with invalid pw: ${pw}`, logger.GetColor('cyan')) - if (redirectTo) { - res.redirect(redirectTo) // TODO - } else { - res.json({ - msg: 'invalid pw' - }) - } + res.json({ + result: 'error', + msg: 'Invalid password' + }) } }) diff --git a/modules/qmining/qmining.js b/modules/qmining/qmining.js index ba18266..e89de38 100644 --- a/modules/qmining/qmining.js +++ b/modules/qmining/qmining.js @@ -53,7 +53,8 @@ function GetApp () { userDB: userDB, jsonResponse: false, exceptions: [ - '/favicon.ico' + '/favicon.ico', + '/getVeteranPw' ] })) app.use(express.static('modules/qmining/public')) @@ -172,6 +173,13 @@ function GetApp () { logger.LogReq(req) }) + app.get('/getVeteranPw', function (req, res) { + res.render('veteranPw', { + cid: req.query.cid + }) + logger.LogReq(req) + }) + app.get('*', function (req, res) { res.status(404).render('404') }) diff --git a/modules/qmining/views/veteranPw.ejs b/modules/qmining/views/veteranPw.ejs new file mode 100644 index 0000000..af891d4 --- /dev/null +++ b/modules/qmining/views/veteranPw.ejs @@ -0,0 +1,117 @@ + + + + + Frylabs + + + + +
+
+ Frylabs +
+
+ Másold be ide régi kliens ID-d, és az alapján jelszót ad. Ezt csak egyszer teheted meg, a + kapott jelszót tuti helyre írd le! +
+
+
+ +
+ + +
+
+ + + diff --git a/sharedViews/login.ejs b/sharedViews/login.ejs index 368dbd5..292bbf8 100644 --- a/sharedViews/login.ejs +++ b/sharedViews/login.ejs @@ -21,6 +21,11 @@ text-align: center; } + .text { + font-size: 18px; + color: white; + margin: 20px; + } .title { font-size: 50px; font-weight: bold; @@ -45,7 +50,7 @@ input[type=text], input[type=password]:focus { border: 2px solid #000; } - input[type=button], input[type=submit], input[type=reset] { + button { background-color: #9999ff; border: none; color: white; @@ -60,16 +65,17 @@
Frylabs
-
+
+
+
- autocomplete="off"/> - - + +