Skip to content

Commit f6cfdad

Browse files
committed
implement login throttle limit of 50 per minute removed from libnest
1 parent aaf4740 commit f6cfdad

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

apps/api/src/auth/auth.controller.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { CurrentUser } from '@douglasneuroinformatics/libnest';
22
import type { RequestUser } from '@douglasneuroinformatics/libnest';
33
import { Body, Controller, Get, HttpCode, HttpStatus, Post } from '@nestjs/common';
44
import { ApiOperation } from '@nestjs/swagger';
5+
import { Throttle } from '@nestjs/throttler';
56
import { $LoginCredentials } from '@opendatacapture/schemas/auth';
67

78
import { RouteAccess } from '@/core/decorators/route-access.decorator.js';
@@ -15,6 +16,7 @@ export class AuthController {
1516
@Get('create-instrument-token')
1617
@HttpCode(HttpStatus.OK)
1718
@RouteAccess({ action: 'create', subject: 'Instrument' })
19+
@Throttle({ long: { limit: 50, ttl: 60_000 } })
1820
async getCreateInstrumentToken(@CurrentUser() currentUser: RequestUser): Promise<{ accessToken: string }> {
1921
return this.authService.getCreateInstrumentToken(currentUser);
2022
}
@@ -23,6 +25,7 @@ export class AuthController {
2325
@HttpCode(HttpStatus.OK)
2426
@Post('login')
2527
@RouteAccess('public')
28+
@Throttle({ long: { limit: 50, ttl: 60_000 } })
2629
async login(@Body() credentials: $LoginCredentials): Promise<{ accessToken: string }> {
2730
return this.authService.login(credentials);
2831
}

0 commit comments

Comments
 (0)