This repository was archived by the owner on Jan 28, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,10 +18,10 @@ export class AuthController {
1818 @Post ( 'login' )
1919 @UseInterceptors ( LoginLoggingInterceptor )
2020 @ZodValidation ( loginSchema )
21- @ApiOperation ( { summary : 'Вход пользователя' } )
21+ @ApiOperation ( { summary : 'Вход пользователя (только для администраторов) ' } )
2222 @ApiBody ( { type : LoginDtoClass } )
2323 @ApiResponse ( { status : 200 , description : 'Успешный вход' , type : LoginDtoClass } )
24- @ApiResponse ( { status : 401 , description : 'Неверный email или пароль' } )
24+ @ApiResponse ( { status : 401 , description : 'Неверный email или пароль, либо недостаточно прав ' } )
2525 login ( @Body ( ) loginDto : LoginDto ) {
2626 return this . authService . login ( loginDto ) ;
2727 }
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ export class AuthService {
4848
4949 // Проверяем, что пользователь имеет роль ADMIN
5050 if ( user . role !== 'ADMIN' ) {
51- throw new BadRequestException ( 'Доступ разрешен только администраторам' ) ;
51+ throw new UnauthorizedException ( 'Доступ разрешен только администраторам' ) ;
5252 }
5353
5454 const payload = { email : user . email , sub : user . id } ;
@@ -72,6 +72,8 @@ export class AuthService {
7272 } ;
7373 } catch ( error ) {
7474 this . logger . error ( error ) ;
75+ // Пробрасываем ошибку дальше, чтобы она вернулась клиенту
76+ throw error ;
7577 }
7678 }
7779
@@ -89,7 +91,7 @@ export class AuthService {
8991
9092 // Проверяем, что пользователь имеет роль ADMIN
9193 if ( user . role !== 'ADMIN' ) {
92- throw new BadRequestException ( 'Доступ разрешен только администраторам' ) ;
94+ throw new UnauthorizedException ( 'Доступ разрешен только администраторам' ) ;
9395 }
9496
9597 const newPayload = { email : user . email , sub : user . id } ;
You can’t perform that action at this time.
0 commit comments