发送验证码、登陆接口限流20/min
This commit is contained in:
@@ -21,7 +21,7 @@ export class AuthController {
|
|||||||
|
|
||||||
@Post('login')
|
@Post('login')
|
||||||
@UseGuards(ThrottlerGuard)
|
@UseGuards(ThrottlerGuard)
|
||||||
@Throttle({ default: { limit: 100, ttl: 60000 } })
|
@Throttle({ default: { limit: 20, ttl: 60000 } })
|
||||||
async login(@Body() loginDto: LoginDto) {
|
async login(@Body() loginDto: LoginDto) {
|
||||||
switch (loginDto.type) {
|
switch (loginDto.type) {
|
||||||
case 'password':
|
case 'password':
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
import { BadRequestException, Body, Controller, Post } from '@nestjs/common';
|
import { BadRequestException, Body, Controller, Post, UseGuards } from '@nestjs/common';
|
||||||
import { SendVerificationCodeDto } from './dto/send-verification-code.dto';
|
import { SendVerificationCodeDto } from './dto/send-verification-code.dto';
|
||||||
import { VerificationService } from './verification.service';
|
import { VerificationService } from './verification.service';
|
||||||
|
import { Throttle, ThrottlerGuard } from '@nestjs/throttler';
|
||||||
|
|
||||||
@Controller('verification')
|
@Controller('verification')
|
||||||
export class VerificationController {
|
export class VerificationController {
|
||||||
constructor(private readonly verificationService: VerificationService) { }
|
constructor(private readonly verificationService: VerificationService) { }
|
||||||
|
|
||||||
@Post('send')
|
@Post('send')
|
||||||
|
@UseGuards(ThrottlerGuard)
|
||||||
|
@Throttle({ default: { limit: 20, ttl: 60000 } })
|
||||||
async sendVerificationCode(@Body() dto: SendVerificationCodeDto) {
|
async sendVerificationCode(@Body() dto: SendVerificationCodeDto) {
|
||||||
switch (dto.type) {
|
switch (dto.type) {
|
||||||
case 'login':
|
case 'login':
|
||||||
|
|||||||
Reference in New Issue
Block a user