mirror of
https://github.com/wassname/talk.git
synced 2026-07-21 12:51:03 +08:00
reintroduced the errors.ErrSameUsernameProvided
This commit is contained in:
@@ -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
@@ -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');
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user