Files
IdP/apps/api-gateway/src/controllers/otp.controller.ts
2026-06-24 14:37:15 +03:00

27 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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);
}
}