fix(auth): account for new username paradigm in add-local flow

This commit is contained in:
Sabe Jones 2018-10-03 14:01:45 -05:00
parent 8b610d771c
commit 45a757b589
2 changed files with 1 additions and 2 deletions

View file

@ -42,7 +42,6 @@
"messageAuthPasswordMustMatch": ":password and :confirmPassword don't match",
"messageAuthCredentialsRequired": ":username, :email, :password, :confirmPassword required",
"messageAuthUsernameTaken": "Username already taken",
"messageAuthEmailTaken": "Email already taken",
"messageAuthNoUserFound": "No user found.",
"messageAuthMustBeLoggedIn": "You must be logged in.",

View file

@ -117,7 +117,7 @@ async function registerLocal (req, res, { isV3 = false }) {
if (user) {
if (email === user.auth.local.email) throw new NotAuthorized(res.t('emailTaken'));
// Check that the lowercase username isn't already used
if (lowerCaseUsername === user.auth.local.lowerCaseUsername) throw new NotAuthorized(res.t('usernameTaken'));
if (lowerCaseUsername === user.auth.local.lowerCaseUsername && existingUser._id !== user._id) throw new NotAuthorized(res.t('usernameTaken'));
}
let hashed_password = await passwordUtils.bcryptHash(password); // eslint-disable-line camelcase