Skip to content

Commit 7bbbe0a

Browse files
committed
feat: add throttling to user invitation and login endpoints
1 parent 468d78a commit 7bbbe0a

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

backend/src/entities/company-info/company-info.controller.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ export class CompanyInfoController {
224224
type: InvitedUserInCompanyAndConnectionGroupDs,
225225
})
226226
@UseGuards(CompanyAdminGuard)
227+
@Throttle({ default: { limit: isTest() ? 200 : 10, ttl: 60000 } })
227228
@Put('user/:companyId')
228229
async inviteUserInCompanyAndConnectionGroup(
229230
@UserId() userId: string,

backend/src/entities/user/user.controller.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ import { UserSettingsDataRequestDto } from './dto/user-settings-data-request.dto
7171
import { RequestRestUserPasswordDto } from './dto/request-rest-user-password.dto.js';
7272
import { SuccessResponse } from '../../microservices/saas-microservice/data-structures/common-responce.ds.js';
7373
import { Timeout } from '../../decorators/timeout.decorator.js';
74+
import { Throttle } from '@nestjs/throttler';
75+
import { isTest } from '../../helpers/app/is-test.js';
7476

7577
@UseInterceptors(SentryInterceptor)
7678
@Timeout()
@@ -143,6 +145,7 @@ export class UserController {
143145
description: 'Login successful.',
144146
type: TokenExpDs,
145147
})
148+
@Throttle({ default: { limit: isTest() ? 200 : 5, ttl: 60000 } })
146149
@Post('user/login/')
147150
async usualLogin(
148151
@Res({ passthrough: true }) response: Response,

0 commit comments

Comments
 (0)