Make UID case-insensitive
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-10-18 23:27:23 -05:00
parent 2d97b77bbf
commit 97096f619f
14 changed files with 32 additions and 31 deletions

View File

@@ -96,7 +96,7 @@ class LDAPController extends Controller {
// Make sure the uid is free
const User = this.models.get('auth:User')
const existing_user = await User.findOne({ uid: req.body.uid })
const existing_user = await User.findOne({ uid: req.body.uid.toLowerCase() })
if ( existing_user )
return res.status(400)
.message(req.T('api.user_already_exists'))
@@ -113,7 +113,7 @@ class LDAPController extends Controller {
// Create the client
const Client = this.models.get('ldap:Client')
const client = await Client.create({
uid: req.body.uid,
uid: req.body.uid.toLowerCase(),
password: req.body.password,
name: req.body.name,
})
@@ -210,16 +210,16 @@ class LDAPController extends Controller {
}
// Update the uid
if ( req.body.uid !== user.uid ) {
if ( req.body.uid.toLowerCase() !== user.uid ) {
// Make sure the UID is free
const User = this.models.get('auth:User')
const existing_user = await User.findOne({ uid: req.body.uid })
const existing_user = await User.findOne({ uid: req.body.uid.toLowerCase() })
if ( existing_user )
return res.status(400)
.message(req.T('api.user_already_exists'))
.api()
user.uid = req.body.uid
user.uid = req.body.uid.toLowerCase()
}
// Update the password