fix idp on started
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { Body, Controller, Delete, Get, Param, Put, UseGuards, UsePipes, ValidationPipe } from '@nestjs/common';
|
||||
import { Body, Controller, Delete, Get, Param, Post, Put, UseGuards, UsePipes, ValidationPipe } from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiBody, ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { map } from 'rxjs';
|
||||
import { CoreGrpcService } from '../core-grpc.service';
|
||||
import { CurrentAdmin } from '../decorators/current-admin.decorator';
|
||||
import { ConnectLinkedAccountDto, UpsertSettingDto, UpsertSocialProviderDto } from '../dto/settings.dto';
|
||||
import { ConnectLinkedAccountDto, TestMessagingDeliveryDto, UpsertSettingDto, UpsertSocialProviderDto } from '../dto/settings.dto';
|
||||
import { AdminGuard, AdminRequestUser, assertAdminPermission } from '../guards/admin.guard';
|
||||
|
||||
const settingsWritePipe = new ValidationPipe({
|
||||
@@ -97,6 +97,16 @@ export class SettingsController {
|
||||
return this.core.settings.DeleteSocialProvider({ providerName });
|
||||
}
|
||||
|
||||
@Post('messaging/test')
|
||||
@UsePipes(settingsWritePipe)
|
||||
@ApiOperation({ summary: 'Тест email/SMS', description: 'Отправляет тестовый OTP-код через настроенного провайдера.' })
|
||||
@ApiBody({ type: TestMessagingDeliveryDto })
|
||||
@ApiResponse({ status: 200, description: 'Тестовое сообщение отправлено' })
|
||||
testMessaging(@Body() dto: TestMessagingDeliveryDto, @CurrentAdmin() admin: AdminRequestUser) {
|
||||
assertAdminPermission(admin, 'canManageSettings');
|
||||
return this.core.settings.TestMessagingDelivery({ channel: dto.channel, target: dto.target });
|
||||
}
|
||||
|
||||
@Get('linked-accounts/users/:userId')
|
||||
@ApiOperation({ summary: 'Связанные внешние аккаунты', description: 'Возвращает LinkedAccount записи пользователя для Google/Yandex и других провайдеров.' })
|
||||
@ApiParam({ name: 'userId', description: 'ID пользователя' })
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { IsBoolean, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
import { IsBoolean, IsIn, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
export class UpsertSettingDto {
|
||||
@ApiProperty({ description: 'Ключ настройки', example: 'PIN_LOCK_TIMEOUT_MINUTES' })
|
||||
@@ -43,6 +43,17 @@ export class UpsertSocialProviderDto {
|
||||
isEnabled!: boolean;
|
||||
}
|
||||
|
||||
export class TestMessagingDeliveryDto {
|
||||
@ApiProperty({ description: 'Канал доставки', enum: ['email', 'sms'] })
|
||||
@IsIn(['email', 'sms'], { message: 'Канал должен быть email или sms' })
|
||||
channel!: 'email' | 'sms';
|
||||
|
||||
@ApiProperty({ description: 'Email или номер телефона получателя', example: 'user@example.com' })
|
||||
@IsString({ message: 'Получатель должен быть строкой' })
|
||||
@IsNotEmpty({ message: 'Укажите email или телефон' })
|
||||
target!: string;
|
||||
}
|
||||
|
||||
export class ConnectLinkedAccountDto {
|
||||
@ApiProperty({ description: 'Название провайдера', example: 'google' })
|
||||
@IsString({ message: 'Название провайдера должно быть строкой' })
|
||||
|
||||
Reference in New Issue
Block a user