Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[_]: feat/return 403 instead of 401 when account is blocked #421

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/routes/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class AuthController {
const loginAttemptsLimitReached = userData.errorLoginCount >= MAX_LOGIN_FAIL_ATTEMPTS;

if (loginAttemptsLimitReached) {
throw createHttpError(401, 'Your account has been blocked for security reasons. Please reach out to us');
throw createHttpError(403, 'Your account has been blocked for security reasons. Please reach out to us');
}

const hashedPass = this.service.Crypt.decryptText(req.body.password);
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ describe('E2E TEST', () => {
.post('/api/access')
.send({ ...TEST_USER_LOGIN_BODY });

expect(status).toBe(HttpStatus.UNAUTHORIZED);
expect(status).toBe(HttpStatus.FORBIDDEN);
expect(body.error).toBe('Your account has been blocked for security reasons. Please reach out to us');
});
});
Expand Down
Loading