chore: add new route to get admin permissons
This commit is contained in:
@@ -86,6 +86,16 @@ export class AdminsService {
|
||||
}
|
||||
/************************************************************ */
|
||||
|
||||
async getAdminPermissions(userId: string) {
|
||||
const user = await this.userRepository.findOne({ where: { id: userId }, relations: { roles: { permissions: true } } });
|
||||
if (!user) throw new BadRequestException(UserMessage.USER_NOT_FOUND);
|
||||
|
||||
return {
|
||||
permissions: user.roles[0].permissions,
|
||||
};
|
||||
}
|
||||
/************************************************************ */
|
||||
|
||||
async getRoles(queryDto: SearchRolesQueryDto) {
|
||||
const { limit, skip } = PaginationUtils(queryDto);
|
||||
const queryBuilder = this.rolesRepository.createQueryBuilder("role");
|
||||
|
||||
@@ -191,6 +191,13 @@ export class UsersController {
|
||||
return this.adminsService.createAdmin(createDto);
|
||||
}
|
||||
|
||||
@ApiOperation({ summary: "get admin permissions" })
|
||||
@AuthGuards()
|
||||
@Get("admin-permissions")
|
||||
getAdminPermissions(@UserDec("id") userId: string) {
|
||||
return this.adminsService.getAdminPermissions(userId);
|
||||
}
|
||||
|
||||
@ApiOperation({ summary: "get all permissions ==> admin route" })
|
||||
@AuthGuards()
|
||||
@PermissionsDec(PermissionEnum.ADMINS, PermissionEnum.CUSTOMERS)
|
||||
|
||||
Reference in New Issue
Block a user