Se corrigió envio de correos y creacion de controller servicio

This commit is contained in:
2025-10-21 14:54:31 -06:00
parent 86b0096350
commit de24bdeec0
11 changed files with 709 additions and 432 deletions
+39
View File
@@ -0,0 +1,39 @@
import {
Controller,
Post,
Body,
Get,
Query,
UnauthorizedException,
} from '@nestjs/common';
import { AuthService } from './auth.service';
@Controller('auth')
export class AuthController {
constructor(private readonly authService: AuthService) {}
// ===================== LOGIN =====================
@Post('login')
async login(
@Body('usuario') usuario: string,
@Body('password') password: string,
) {
try {
const token = await this.authService.login(usuario, password);
return token; // { access_token: '...' }
} catch (error) {
throw new UnauthorizedException(error.message);
}
}
// ===================== VERIFICAR TOKEN =====================
@Get('verify')
async verify(@Query('token') token: string) {
try {
const payload = await this.authService.jwtVerificar(token);
return { valid: true, payload };
} catch (error) {
throw new UnauthorizedException(error.message);
}
}
}