Skip to content

Commit 6569fc8

Browse files
committed
fix: change exception on invalid login from 401 to 403
1 parent 36aba6a commit 6569fc8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/auth/local.strategy.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { Strategy } from 'passport-local';
22
import { PassportStrategy } from '@nestjs/passport';
3-
import { Inject, Injectable, UnauthorizedException } from '@nestjs/common';
3+
import {
4+
ForbiddenException,
5+
Inject,
6+
Injectable,
7+
UnauthorizedException,
8+
} from '@nestjs/common';
49
import { AuthService } from './auth.service';
510

611
@Injectable()
@@ -15,7 +20,7 @@ export class LocalStrategy extends PassportStrategy(Strategy) {
1520
async validate(email: string, password: string): Promise<any> {
1621
const user = await this.authService.validateUser(email, password);
1722
if (!user) {
18-
throw new UnauthorizedException('Неверные учетные данные');
23+
throw new ForbiddenException('Неверные учетные данные');
1924
}
2025
return user;
2126
}

0 commit comments

Comments
 (0)