Skip to content

Commit

Permalink
fix(api): use more masterKey (#941)
Browse files Browse the repository at this point in the history
  • Loading branch information
leeyeh authored Oct 19, 2023
1 parent f560d68 commit a44c04f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion next/api/src/controller/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class GroupController {
}

@Get(':id')
async findOne(@Param('id', new FindModelPipe(Group)) group: Group) {
async findOne(@Param('id', new FindModelPipe(Group, { useMasterKey: true })) group: Group) {
const role = await this.findGroupRole(group, { useMasterKey: true });
const users = await role.getUsers().query().find({ useMasterKey: true });
const userIds = users.map((u) => u.id!);
Expand Down
4 changes: 2 additions & 2 deletions next/api/src/controller/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
UseMiddlewares,
} from '@/common/http';
import { ZodValidationPipe } from '@/common/pipe';
import { customerServiceOnly } from '@/middleware';
import { customerServiceOnly, staffOnly } from '@/middleware';
import { UpdateData } from '@/orm';
import router from '@/router/ticket';
import { Ticket } from '@/model/Ticket';
Expand All @@ -27,7 +27,7 @@ const createAssociatedTicketSchema = z.object({
@Controller({ router, path: 'tickets' })
export class TicketController {
@Get(':id/associated-tickets')
@UseMiddlewares(customerServiceOnly)
@UseMiddlewares(staffOnly)
@ResponseBody(TicketListItemResponse)
getAssociatedTickets(@Ctx() ctx: Context) {
const ticket = ctx.state.ticket as Ticket;
Expand Down
2 changes: 1 addition & 1 deletion next/api/src/controller/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class UserController {
@Get(':id')
@UseMiddlewares(auth, staffOnly)
@ResponseBody(UserResponse)
findOne(@Param('id', new FindModelPipe(User)) user: User) {
findOne(@Param('id', new FindModelPipe(User, {useMasterKey: true})) user: User) {
return user;
}

Expand Down

0 comments on commit a44c04f

Please sign in to comment.