Backend: - Add SmsService + SmsModule: send OTP via u-site.app provider, 5-min TTL - Auth endpoints: POST /auth/send-otp, POST /auth/phone (login by phone+code), POST /auth/verify-phone (link), PATCH /auth/change-password - is_phone_verified included in JWT token response - GET /comments (admin, JWT-protected) with author/destination names Admin: - Users list: link to detail page per row - User detail: inline edit form (name, city, phone) with PATCH /users/:id - Services list: link to detail page per row - Service detail: status change dropdown (PATCH /services/:id/status) - New Comments page: summary stats + full table with star ratings - New SMS settings page: configure API key + send test SMS - Sidebar: added Comments and SMS entries Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import { Controller, Get, Patch, Post, Body, UseGuards } from '@nestjs/common';
|
|
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
|
|
import { IsString } from 'class-validator';
|
|
import { SmsService } from './sms.service';
|
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
|
|
|
class SaveConfigDto {
|
|
@IsString()
|
|
api_key: string;
|
|
}
|
|
|
|
class TestSmsDto {
|
|
@IsString()
|
|
numero: string;
|
|
|
|
@IsString()
|
|
mensaje: string;
|
|
}
|
|
|
|
@ApiTags('SMS')
|
|
@Controller('sms')
|
|
@UseGuards(JwtAuthGuard)
|
|
@ApiBearerAuth()
|
|
export class SmsController {
|
|
constructor(private sms: SmsService) {}
|
|
|
|
@Get('config')
|
|
async getConfig() {
|
|
const config = await this.sms.getConfig();
|
|
if (!config?.api_key) return { configured: false, api_key_preview: '' };
|
|
const k = config.api_key;
|
|
const preview = k.length > 8 ? `${k.slice(0, 8)}••••••••${k.slice(-4)}` : '••••••••';
|
|
return { configured: true, api_key_preview: preview };
|
|
}
|
|
|
|
@Patch('config')
|
|
async saveConfig(@Body() dto: SaveConfigDto) {
|
|
await this.sms.saveConfig(dto.api_key);
|
|
return { ok: true };
|
|
}
|
|
|
|
@Post('test')
|
|
test(@Body() dto: TestSmsDto) {
|
|
return this.sms.send(dto.numero, dto.mensaje);
|
|
}
|
|
}
|