This commit is contained in:
2025-10-24 13:43:00 -06:00
parent a2be3ee273
commit 0cdd4e178f
11 changed files with 223 additions and 63 deletions
+2 -4
View File
@@ -4,9 +4,6 @@ import * as argon2 from 'argon2';
import { LoginDto } from './dto/login.dto';
import { CreateUsuarioDto } from 'src/usuarios/dto/create-usuario.dto';
import { JwtService } from '@nestjs/jwt';
import { Repository } from 'typeorm';
import { Usuario } from 'src/usuarios/entities/usuario.entity';
import { InjectRepository } from '@nestjs/typeorm';
@Injectable()
export class AuthService {
@@ -14,7 +11,7 @@ export class AuthService {
private readonly usuarioService:UsuariosService,
private readonly jwtService:JwtService
){}
//Pendiente tipoUsuario
async registro({nombre, contraseña,tipoUsuario}: CreateUsuarioDto){
const usuario = await this.usuarioService.findOneByName(nombre);
@@ -62,6 +59,7 @@ export class AuthService {
token:token,
};
}
+4
View File
@@ -2,7 +2,11 @@ import { PassportStrategy } from "@nestjs/passport";
import{ExtractJwt,Strategy} from 'passport-jwt'
export class JwtStrategy extends PassportStrategy(Strategy){
constructor(){
if( !process.env.JWT ){
throw new Error('JWT_SECRET no está definido en las variables de entorno');
}
super({
jwtFromRequest:ExtractJwt.fromAuthHeaderAsBearerToken(),
ignoreExpiration:false,