fix: Invalid credentials should throw 401 and not 500 (no-changelog) (#4703)

fix: invalid credentials should throw 401 and not 500

I missed to add these in https://github.com/n8n-io/n8n/pull/4691

I've checked not that there are no other cases of http errors that aren't using error classes. This was the last one.
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2022-11-23 16:03:47 +01:00 committed by GitHub
parent 36dc5f0e66
commit f63cd3b89e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -43,11 +43,7 @@ export function authenticationMethods(this: N8nApp): void {
}
if (!user?.password || !(await compareHash(req.body.password, user.password))) {
// password is empty until user signs up
const error = new Error('Wrong username or password. Do you have caps lock on?');
// @ts-ignore
error.httpStatusCode = 401;
throw error;
throw new ResponseHelper.AuthError('Wrong username or password. Do you have caps lock on?');
}
await issueCookie(res, user);