more fix and update

This commit is contained in:
lendry
2026-06-24 20:15:19 +03:00
parent dcab6557d3
commit 9727cf3f35
53 changed files with 3479 additions and 494 deletions

View File

@@ -1,9 +1,9 @@
import { Body, Controller, Get, Headers, Post } from '@nestjs/common';
import { Body, Controller, Get, Headers, Ip, Post } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
import { ApiBearerAuth, ApiBody, ApiOperation, ApiTags } from '@nestjs/swagger';
import { firstValueFrom } from 'rxjs';
import { CoreGrpcService } from '../core-grpc.service';
import { IdentifyDto, LdapLoginDto, LoginDto, PasswordlessOtpDto, PasswordlessVerifyDto, PasswordLoginDto, RefreshSessionDto, RegisterDto, VerifyPinDto } from '../dto/auth.dto';
import { BeginTotpLoginDto, IdentifyDto, LdapLoginDto, LoginDto, PasswordlessOtpDto, PasswordlessVerifyDto, PasswordLoginDto, RefreshSessionDto, RegisterDto, VerifyPinDto, VerifyTotpLoginDto } from '../dto/auth.dto';
import { resolveAuthorizedPayload, verifyAccessToken } from '../session-auth';
@ApiTags('Аутентификация')
@@ -38,8 +38,8 @@ export class AuthController {
@Post('otp/send')
@ApiOperation({ summary: 'Отправить OTP для входа', description: 'Passwordless-first вход: пользователь вводит почту или телефон, сервер создает 6-значный код и пишет его в console.log.' })
@ApiBody({ type: PasswordlessOtpDto })
sendOtp(@Body() dto: PasswordlessOtpDto) {
return this.core.auth.SendOtp({ recipient: dto.recipient, channel: dto.channel });
sendOtp(@Body() dto: PasswordlessOtpDto, @Ip() ipAddress?: string) {
return this.core.auth.SendOtp({ recipient: dto.recipient, channel: dto.channel, ipAddress });
}
@Post('otp/verify')
@@ -70,6 +70,20 @@ export class AuthController {
return this.core.auth.VerifyPin(dto);
}
@Post('totp/begin')
@ApiOperation({ summary: 'Начать вход по TOTP', description: 'Создаёт challenge для входа через приложение-аутентификатор вместо SMS/email OTP.' })
@ApiBody({ type: BeginTotpLoginDto })
beginTotpLogin(@Body() dto: BeginTotpLoginDto) {
return this.core.auth.BeginTotpLogin(dto);
}
@Post('totp/verify')
@ApiOperation({ summary: 'Подтвердить TOTP при входе', description: 'Завершает вход после проверки кода из Google Authenticator или аналога.' })
@ApiBody({ type: VerifyTotpLoginDto })
verifyTotpLogin(@Body() dto: VerifyTotpLoginDto) {
return this.core.auth.VerifyTotpLogin(dto);
}
@Post('refresh')
@ApiOperation({ summary: 'Обновить access token', description: 'Обновляет JWT по refresh token. Если сессия заблокирована PIN-кодом, возвращает requiresPin=true без выхода из аккаунта.' })
@ApiBody({ type: RefreshSessionDto })