This commit is contained in:
2026-03-04 14:20:47 -05:00
parent 04290f4097
commit 81ad881d6a
2 changed files with 24 additions and 0 deletions
+9
View File
@@ -6,6 +6,7 @@ import {
UseGuards,
Res,
Req,
Param,
} from '@nestjs/common';
import type { Response } from 'express';
import { UserService } from './user.service';
@@ -21,6 +22,12 @@ export class UserController {
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get('/switch/:id')
async getactive(@Param('id') id:number) {
return this.userService.getactive(id);
}
@Get()
async getAll() {
return this.userService.getAll();
@@ -45,7 +52,9 @@ export class UserController {
}
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Post('/create')
async createUser(@Body() data: CreateUserDto) {
return this.userService.create(data);
+15
View File
@@ -21,6 +21,21 @@ export class UserService {
private jwtService: JwtService,
) {}
async getactive(id: number) {
const user = await this.userRepository.findOne({
where: { id_usuario: id },
});
if (!user) {
throw new NotFoundException('Usuario no encontrado');
}
user.activo = user.activo === 1 ? 0 : 1;
return this.userRepository.save(user);
}
async findOneByNameandPassword(data: Login): Promise<User> {
const { usuario, password } = data;