mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-14 19:47:03 +00:00
fix(auth): Don't try to check existing username on new reg
This commit is contained in:
parent
fead027cd2
commit
90d35d2f1f
2 changed files with 6 additions and 2 deletions
|
|
@ -473,7 +473,7 @@ describe('POST /user/auth/local/register', () => {
|
|||
});
|
||||
|
||||
it('rejects if username is already taken', async () => {
|
||||
let uniqueEmail = `${generateRandomUserName()}@exampe.com`;
|
||||
let uniqueEmail = `${generateRandomUserName()}@example.com`;
|
||||
let password = 'password';
|
||||
|
||||
await expect(api.post('/user/auth/local/register', {
|
||||
|
|
|
|||
|
|
@ -117,7 +117,11 @@ 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 && existingUser._id !== user._id) throw new NotAuthorized(res.t('usernameTaken'));
|
||||
if (existingUser) {
|
||||
if (lowerCaseUsername === user.auth.local.lowerCaseUsername && existingUser._id !== user._id) throw new NotAuthorized(res.t('usernameTaken'));
|
||||
} else if (lowerCaseUsername === user.auth.local.lowerCaseUsername) {
|
||||
throw new NotAuthorized(res.t('usernameTaken'));
|
||||
}
|
||||
}
|
||||
|
||||
let hashed_password = await passwordUtils.bcryptHash(password); // eslint-disable-line camelcase
|
||||
|
|
|
|||
Loading…
Reference in a new issue