first commit
This commit is contained in:
26
apps/api-gateway/src/controllers/otp.controller.ts
Normal file
26
apps/api-gateway/src/controllers/otp.controller.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Body, Controller, Post } from '@nestjs/common';
|
||||
import { ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { CoreGrpcService } from '../core-grpc.service';
|
||||
import { SendOtpDto, VerifyOtpDto } from '../dto/identity.dto';
|
||||
|
||||
@ApiTags('OTP и 2FA')
|
||||
@Controller('auth/otp')
|
||||
export class OtpController {
|
||||
constructor(private readonly core: CoreGrpcService) {}
|
||||
|
||||
@Post('send')
|
||||
@ApiOperation({ summary: 'Отправить OTP код', description: 'Создает одноразовый код в AuthCode. Fallback-доставка пишет код в console.log.' })
|
||||
@ApiBody({ type: SendOtpDto })
|
||||
@ApiResponse({ status: 201, description: 'Код создан и отправлен' })
|
||||
send(@Body() dto: SendOtpDto) {
|
||||
return this.core.otp.SendOtp(dto);
|
||||
}
|
||||
|
||||
@Post('verify')
|
||||
@ApiOperation({ summary: 'Проверить OTP код', description: 'Проверяет одноразовый код, срок жизни и помечает его использованным.' })
|
||||
@ApiBody({ type: VerifyOtpDto })
|
||||
@ApiResponse({ status: 201, description: 'Код подтвержден' })
|
||||
verify(@Body() dto: VerifyOtpDto) {
|
||||
return this.core.otp.VerifyOtp(dto);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user