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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue