Files
prosapp-migration/backend/src/users/users.controller.ts
T
Lizandro GuarnizoandClaude Sonnet 4.6 a8842a2728 feat(users): add block/unblock and delete from admin panel
- Migration 0004: adds is_active column to users table
- Backend: DELETE /users/:id endpoint + is_active field in UpdateUserDto
- Admin UI: block/unblock toggle and delete with confirmation on user detail
- Users list: shows "Bloqueado" badge for inactive users

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-02 14:55:16 -05:00

59 lines
1.5 KiB
TypeScript

import { Controller, Get, Patch, Delete, Param, Body, UseGuards, Req } from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { UsersService } from './users.service';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { UpdateUserDto, FcmTokenDto } from '../auth/dto/auth.dto';
@ApiTags('Users')
@Controller('users')
export class UsersController {
constructor(private users: UsersService) {}
@Get()
findAll(@Req() req) {
const page = +(req.query.page || 1);
const limit = +(req.query.limit || 20);
return this.users.findAll(page, limit);
}
@Get('me')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
findMe(@Req() req) {
return this.users.findById(req.user.sub);
}
@Patch('me')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
update(@Req() req, @Body() dto: UpdateUserDto) {
return this.users.update(req.user.sub, dto);
}
@Patch('me/fcm-token')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
updateFcmToken(@Req() req, @Body() dto: FcmTokenDto) {
return this.users.updateFcmToken(req.user.sub, dto.token);
}
@Patch(':id')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
updateById(@Param('id') id: string, @Body() dto: UpdateUserDto) {
return this.users.update(id, dto);
}
@Get(':id')
findById(@Param('id') id: string) {
return this.users.findById(id);
}
@Delete(':id')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
deleteById(@Param('id') id: string) {
return this.users.deleteById(id);
}
}