ultima versión

This commit is contained in:
evenegas
2025-06-27 21:49:50 -06:00
parent ccf476bd6e
commit 904db0549f
4 changed files with 49 additions and 31 deletions
+18 -5
View File
@@ -6,20 +6,33 @@ export class AuthService {
constructor(private jwtService: JwtService) { }
generarToken(payload: any) {
console.log('JWT_SECRET:', process.env.JWT_SECRET);
return this.jwtService.sign(payload, {
secret: process.env.JWT_SECRET,
expiresIn: '1d',
});
}
verificarToken(token: string) {
async verificarToken(token: string) {
console.log('JWT_SECRET:', process.env.JWT_SECRET);
console.log('JWT_SECRET:', process.env.JWT_SECRET);
console.log('Verificando token:', token);
try {
return this.jwtService.verify(token, {
const result = await this.jwtService.verify(token, {
secret: process.env.JWT_SECRET,
});
} catch {
return null;
console.log('Resultado de verificación:', result);
return result;
} catch (error) {
throw new Error('Token inválido o expirado');
}
}
}