cambio de inf en los reportes
This commit is contained in:
+18
-17
@@ -1,27 +1,28 @@
|
||||
import { Body, Controller, Get, Post, UseGuards } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Patch, Post, UseGuards } from '@nestjs/common';
|
||||
import { AuthService } from './auth.service';
|
||||
import { CreateUsuarioDto } from 'src/usuarios/dto/create-usuario.dto';
|
||||
import { LoginDto } from './dto/login.dto';
|
||||
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import { UpdateUsuarioDto } from 'src/usuarios/dto/update-usuario.dto';
|
||||
|
||||
@Controller('auth')
|
||||
export class AuthController {
|
||||
constructor( private readonly authService:AuthService){}
|
||||
|
||||
@Post("registro")
|
||||
registro(@Body() registroDto:CreateUsuarioDto ){
|
||||
return this.authService.registro(registroDto);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Post("login")
|
||||
login(@Body() loginDto:LoginDto){
|
||||
return this.authService.login(loginDto);
|
||||
}
|
||||
|
||||
|
||||
constructor(private readonly authService: AuthService) {}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Post('registro')
|
||||
registro(@Body() registroDto: CreateUsuarioDto) {
|
||||
return this.authService.registro(registroDto);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Patch('update')
|
||||
update(@Body() registroDto: UpdateUsuarioDto) {
|
||||
return this.authService.update(registroDto);
|
||||
}
|
||||
|
||||
@Post('login')
|
||||
login(@Body() loginDto: LoginDto) {
|
||||
return this.authService.login(loginDto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import * as bcrypt from 'bcryptjs';
|
||||
import { LoginDto } from './dto/login.dto';
|
||||
import { CreateUsuarioDto } from 'src/usuarios/dto/create-usuario.dto';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { UpdateUsuarioDto } from 'src/usuarios/dto/update-usuario.dto';
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
@@ -17,6 +18,18 @@ export class AuthService {
|
||||
private readonly jwtService: JwtService,
|
||||
) {}
|
||||
|
||||
async update(registroDto: UpdateUsuarioDto) {
|
||||
const update_data = await this.usuarioService.actualizarUsuario(
|
||||
registroDto.id_User,
|
||||
{
|
||||
nombre: registroDto.nombre,
|
||||
contraseña: registroDto.contraseña,
|
||||
id_tipo_usuario: registroDto.tipoUsuario,
|
||||
},
|
||||
);
|
||||
return update_data;
|
||||
}
|
||||
|
||||
async registro({ nombre, contraseña, tipoUsuario }: CreateUsuarioDto) {
|
||||
const usuario = await this.usuarioService.findOneByName(nombre);
|
||||
if (usuario) {
|
||||
|
||||
Reference in New Issue
Block a user