Roles
This commit is contained in:
@@ -14,9 +14,13 @@ import {
|
||||
import { AuthGuard } from './auth.guard';
|
||||
import { AuthService } from './auth.service';
|
||||
import { registerDto } from './dto/registerDto.dto';
|
||||
import { UserDto } from 'src/users/dto/userDto.dto';
|
||||
import {Roles} from '../permissions/roles.decorator'
|
||||
import {RolesGuard} from '../permissions/roles.guard'
|
||||
import {Role} from '../permissions/role.enum'
|
||||
|
||||
|
||||
@Controller('auth')
|
||||
@UseGuards(RolesGuard)
|
||||
export class AuthController {
|
||||
constructor(private authService: AuthService) {}
|
||||
|
||||
@@ -25,8 +29,10 @@ export class AuthController {
|
||||
async signIn(@Body() data: registerDto) {
|
||||
return this.authService.signIn(data);
|
||||
}
|
||||
//@UseGuards()
|
||||
|
||||
@UseGuards()
|
||||
@Post("register")
|
||||
@Roles(Role.Admin)
|
||||
async register(@Body() data: registerDto){
|
||||
return this.authService.register(data)
|
||||
}
|
||||
@@ -37,14 +43,16 @@ export class AuthController {
|
||||
return req.user;
|
||||
}
|
||||
|
||||
//@UseGuards(AuthGuard)
|
||||
@UseGuards(AuthGuard)
|
||||
@Put('Modificacion/:id')
|
||||
@Roles(Role.Admin)
|
||||
async update(@Param('id') userId: number, @Body() data: registerDto) {
|
||||
return this.authService.update(userId, data);
|
||||
}
|
||||
|
||||
//@UseGuards(AuthGuard)
|
||||
@UseGuards(AuthGuard)
|
||||
@Delete('Borrado/:id')
|
||||
@Roles(Role.Admin)
|
||||
async remove(@Param('id') id: number) {
|
||||
await this.authService.remove(id);
|
||||
return { message: 'User successfully deleted' };
|
||||
|
||||
Reference in New Issue
Block a user