Skip to content

Commit

Permalink
chore: update guards
Browse files Browse the repository at this point in the history
  • Loading branch information
1tpp committed Aug 3, 2023
1 parent 48735b7 commit b308465
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/tickets/tickets.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class TicketsController {

@Post()
@Roles(Role.Provider)
@UseGuards(RolesGuard)
@Patch(':id')
async update(
@Param('id') id: string,
Expand All @@ -77,6 +78,7 @@ export class TicketsController {

@Post()
@Roles(Role.Provider)
@UseGuards(RolesGuard)
@Delete(':id')
async remove(@Param('id') id: string) {
const ticketRemoved = await this.ticketsService.remove(id);
Expand Down
7 changes: 6 additions & 1 deletion src/users/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import { UsersService } from './users.service';
@UseGuards(JwtGuard)
@Controller('users')
export class UsersController {
constructor(private readonly usersService: UsersService) { }
constructor(private readonly usersService: UsersService) {}

@Roles(Role.Provider, Role.User)
@UseGuards(RolesGuard)
@Get('/profile')
async getProfile(@GetUser() currentUser) {
const user = await this.usersService.findOneById(currentUser._id);
Expand All @@ -28,6 +29,7 @@ export class UsersController {
}

@Roles(Role.Admin)
@UseGuards(RolesGuard)
@Get()
async findAll() {
const users = await this.usersService.findAll();
Expand All @@ -39,6 +41,7 @@ export class UsersController {
}

@Roles(Role.Admin)
@UseGuards(RolesGuard)
@Get(':id')
async findOne(id: string) {
const user = await this.usersService.findOneById(id);
Expand All @@ -51,6 +54,7 @@ export class UsersController {

// Find by username
@Roles(Role.Admin)
@UseGuards(RolesGuard)
@Get('/username/:username')
async findOneByUsername(username: string) {
const user = await this.usersService.findOneByUsername(username);
Expand All @@ -63,6 +67,7 @@ export class UsersController {

// Find by email
@Roles(Role.Admin)
@UseGuards(RolesGuard)
@Get('/email/:email')
async findOneByEmail(email: string) {
const user = await this.usersService.findOneByEmail(email);
Expand Down

0 comments on commit b308465

Please sign in to comment.