reintroduced the errors.ErrSameUsernameProvided

This commit is contained in:
Wyatt Johnson
2018-01-05 11:31:40 -07:00
parent 7b5993bc60
commit c9bc9a4b10
3 changed files with 8 additions and 2 deletions
+6
View File
@@ -59,6 +59,11 @@ const ErrUsernameTaken = new APIError('Username already in use', {
status: 400
});
const ErrSameUsernameProvided = new APIError('Username provided for change is the same as current', {
translation_key: 'SAME_USERNAME_PROVIDED',
status: 400
});
const ErrSpecialChars = new APIError('No special characters are allowed in a username', {
translation_key: 'NO_SPECIAL_CHARACTERS',
status: 400
@@ -245,5 +250,6 @@ module.exports = {
ErrSettingsNotInit,
ErrSpecialChars,
ErrUsernameTaken,
ErrSameUsernameProvided,
ExtendableError,
};
+1 -1
View File
@@ -281,7 +281,7 @@ class UsersService {
}
if (!resetAllowed && user.username === username) {
throw errors.ErrUsernameTaken;
throw errors.ErrSameUsernameProvided;
}
throw new Error('edit username failed for an unexpected reason');
+1 -1
View File
@@ -238,7 +238,7 @@ describe('services.UsersService', () => {
await UsersService[func](user.id, user.username);
throw new Error('edit was processed successfully');
} catch (err) {
expect(err).have.property('translation_key', 'USERNAME_IN_USE');
expect(err).have.property('translation_key', 'SAME_USERNAME_PROVIDED');
}
} else {
await UsersService[func](user.id, user.username);