change: make user can view only user within branch
This commit is contained in:
parent
cd153b062a
commit
e911695f3a
1 changed files with 6 additions and 0 deletions
|
|
@ -196,6 +196,7 @@ export class UserController extends Controller {
|
|||
@Get()
|
||||
@Security("keycloak")
|
||||
async getUser(
|
||||
@Request() req: RequestWithUser,
|
||||
@Query() userType?: UserType,
|
||||
@Query() zipCode?: string,
|
||||
@Query() includeBranch: boolean = false,
|
||||
|
|
@ -223,6 +224,11 @@ export class UserController extends Controller {
|
|||
],
|
||||
AND: {
|
||||
userRole: { not: "system" },
|
||||
branch: !["system", "head_of_admin", "admin", "branch_admin"].some((v) =>
|
||||
req.user.roles?.includes(v),
|
||||
)
|
||||
? { some: { userId: req.user.sub } }
|
||||
: undefined,
|
||||
},
|
||||
} satisfies Prisma.UserWhereInput;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue