Change: audio player default volume to 100% #118, Change: username case insensitive #117, Fix: allowing multiple users of the same name, Added: experimental scan audio tracks show raw tags #114

This commit is contained in:
advplyr 2021-10-20 18:54:05 -05:00
parent 09aed354b3
commit 7d9ed75a28
9 changed files with 52 additions and 24 deletions

View file

@ -597,6 +597,13 @@ class ApiController {
return res.sendStatus(403)
}
var account = req.body
var username = account.username
var usernameExists = this.db.users.find(u => u.username.toLowerCase() === username.toLowerCase())
if (usernameExists) {
return res.status(500).send('Username already taken')
}
account.id = (Math.trunc(Math.random() * 1000) + Date.now()).toString(36)
account.pash = await this.auth.hashPass(account.password)
delete account.password
@ -610,9 +617,7 @@ class ApiController {
user: newUser.toJSONForBrowser()
})
} else {
res.json({
error: 'Failed to save new user'
})
return res.status(500).send('Failed to save new user')
}
}
@ -628,6 +633,14 @@ class ApiController {
}
var account = req.body
if (account.username !== undefined && account.username !== user.username) {
var usernameExists = this.db.users.find(u => u.username.toLowerCase() === account.username.toLowerCase())
if (usernameExists) {
return res.status(500).send('Username already taken')
}
}
// Updating password
if (account.password) {
account.pash = await this.auth.hashPass(account.password)