Skip to content

Commit

Permalink
fixed login length, server deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
Stalker2106x committed Aug 25, 2023
1 parent b4f9e02 commit 4c0e2cb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
8 changes: 6 additions & 2 deletions routes/player/createPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ module.exports = {
}
},
handler: async (app, req, res, next) => {
if (req.body.LENOM.length < 3 || !/^[a-zA-Z0-9_]*$/.test(req.body.LENOM)) {
res.status(500).send('Username must consist only of alphanumeric characters, and be at least 3 characters long')
if ((req.body.LENOM.length < 2 && req.body.LENOM.length > 15) || !/^[a-zA-Z0-9_]*$/.test(req.body.LENOM)) {
res.status(500).send('Username must consist only of alphanumeric characters, and be between 2 and 15 characters long')
return
}
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(req.body.LEMAIL)) {
Expand All @@ -30,6 +30,10 @@ module.exports = {
res.status(500).send('LESOFT must be 2')
return
}
if (req.body.LEPASS.length < 2 && req.body.LEPASS.length > 10) {
res.status(500).send('Password length should be between 2 and 10')
return
}
const player = await app.db.models.Players.findOne({
where: {
[Op.or]: {
Expand Down
7 changes: 4 additions & 3 deletions routes/server/deleteServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ module.exports = {
}
},
handler: (app, req, res, next) => {
const server = app.serverList[app.serverList.findIndex((serv) => serv.owner === parseInt(req.body.LENUM))]
const serverIndex = app.serverList.findIndex((serv) => serv.owner === parseInt(req.body.LENUM))
const server = app.serverList[serverIndex]
if (!server) {
res.status(500).send({ error: 'Invalid SERVERID' })
} else {
app.serverList.delete(parseInt(req.body.LENUM))
utils.logger('game', `Server ${server.name} created by ${server.owner} terminated`)
app.serverList.splice(serverIndex, 1)
utils.logger('game', `Deleted server ${server.name} created by ${server.owner}`)
res.status(200).send()
}
next()
Expand Down
8 changes: 4 additions & 4 deletions web/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ <h2>Register</h2>
warning.style.display = 'block'
return;
}
if (username.length < 3) {
if (username.length < 2 || username.length > 15) {
const warning = document.getElementById('usernameWarning')
warning.innerText = 'Username must be of at least 3 characters'
warning.innerText = 'Username must be between 2 and 15 characters'
warning.style.display = 'block'
return;
}
Expand All @@ -75,9 +75,9 @@ <h2>Register</h2>
}

const password = document.getElementById('password').value
if (password.length < 8) {
if (password.length < 2 || password.length > 10) {
const warning = document.getElementById('passwordWarning')
warning.innerText = 'Password must be of at least 8 characters'
warning.innerText = 'Password must be between 2 and 10 characters'
warning.style.display = 'block'
return;
}
Expand Down

0 comments on commit 4c0e2cb

Please sign in to comment.