mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-05-13 05:52:04 +00:00
fix(server): handle PasswordConflict explicitly to avoid a 500 (#1536)
This commit is contained in:
parent
5bd4647414
commit
be0d3b3838
2 changed files with 14 additions and 2 deletions
|
|
@ -532,7 +532,16 @@ describe('ShadowsocksManagerService', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('rejects a password that is already in use', async (done) => {
|
||||
const PASSWORD = 'foobar';
|
||||
await repo.createNewAccessKey({password: PASSWORD});
|
||||
const res = {send: SEND_NOTHING};
|
||||
await serviceMethod({params: {id: accessKeyId, password: PASSWORD}}, res, (error) => {
|
||||
expect(error.statusCode).toEqual(409);
|
||||
responseProcessed = true; // required for afterEach to pass.
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('uses the default port for new keys when no port is provided', async (done) => {
|
||||
const res = {
|
||||
send: (httpCode, data) => {
|
||||
|
|
|
|||
|
|
@ -383,7 +383,10 @@ export class ShadowsocksManagerService {
|
|||
logging.error(error);
|
||||
if (error instanceof errors.InvalidCipher || error instanceof errors.InvalidPortNumber) {
|
||||
throw new restifyErrors.InvalidArgumentError({statusCode: 400}, error.message);
|
||||
} else if (error instanceof errors.PortUnavailable) {
|
||||
} else if (
|
||||
error instanceof errors.PortUnavailable ||
|
||||
error instanceof errors.PasswordConflict
|
||||
) {
|
||||
throw new restifyErrors.ConflictError(error.message);
|
||||
}
|
||||
throw error;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue