Skip to content

Commit

Permalink
Merge pull request #16 from bcgov/emsedt-199-updates
Browse files Browse the repository at this point in the history
Emsedt 199 updates
  • Loading branch information
mgtennant authored Jul 11, 2024
2 parents defcca9 + 607098e commit 7282f8c
Show file tree
Hide file tree
Showing 13 changed files with 1,124 additions and 105 deletions.
33 changes: 33 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@prisma/client": "^5.7.0",
"@types/multer": "^1.4.11",
"axios": "^1.7.2",
"class-validator": "^0.14.1",
"dotenv": "^16.0.1",
"express-prom-bundle": "^7.0.0",
"helmet": "^7.0.0",
Expand Down
39 changes: 38 additions & 1 deletion backend/src/admin/admin.controller.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Controller, Get, UseGuards } from "@nestjs/common";
import { Body, Controller, Get, Post, UseGuards } from "@nestjs/common";
import { AdminService } from "./admin.service";
import { Roles } from "src/auth/decorators/roles.decorators";
import { Role } from "src/enum/role.enum";
import { JwtRoleGuard } from "src/auth/jwtrole.guard";
import { JwtAuthGuard } from "src/auth/jwtauth.guard";
import { UserRolesDto } from "./dto/user-roles.dto";
import { IdirUserInfo } from "src/types/types";

@Controller("admin")
@UseGuards(JwtAuthGuard)
Expand All @@ -16,4 +18,39 @@ export class AdminController {
findAll(): Promise<any[]> {
return this.adminService.findAll();
}

@Post("user-email-search")
userEmailSearch(@Body() body: { email: string }): Promise<IdirUserInfo> {
return this.adminService.userEmailSearch(body.email);
}

@Post("add-roles")
addRoles(
@Body() userRolesDto: UserRolesDto
): Promise<{ userObject: IdirUserInfo; error: string }> {
return this.adminService.addRoles(userRolesDto);
}

@Post("remove-roles")
removeRoles(
@Body() userRolesDto: UserRolesDto
): Promise<{ error: string | null }> {
return this.adminService.removeRoles(userRolesDto);
}

@Post("update-roles")
updateRoles(
@Body()
data: {
idirUsername: string;
existingRoles: string[];
roles: string[];
}
): Promise<{ error: string | null }> {
return this.adminService.updateRoles(
data.idirUsername,
data.existingRoles,
data.roles
);
}
}
Loading

0 comments on commit 7282f8c

Please sign in to comment.