Skip to content

Commit

Permalink
Merge pull request #43 from ReflectionsProjections/dev/aydan/add-staf…
Browse files Browse the repository at this point in the history
…f-role

Added staff-level role
  • Loading branch information
AydanPirani authored May 26, 2024
2 parents 85458b6 + 2b1db99 commit 7ac0a43
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/middleware/role-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ export default function RoleChecker(
return next();
}

// Admins (staff) can access any endpoint
if (userRoles.includes(Role.Enum.ADMIN)) {
// Admins and staff can access any endpoint
if (
userRoles.includes(Role.Enum.ADMIN) ||
userRoles.includes(Role.Enum.STAFF)
) {
return next();
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/auth/auth-models.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from "zod";

export const Role = z.enum(["USER", "ADMIN", "CORPORATE"]);
export const Role = z.enum(["USER", "STAFF", "ADMIN", "CORPORATE"]);

export const JwtPayloadValidator = z.object({
userId: z.string(),
Expand Down
2 changes: 1 addition & 1 deletion src/services/s3/s3-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ s3Router.get(

s3Router.get(
"/download/:USERID",
RoleChecker([Role.enum.ADMIN], false),
RoleChecker([Role.enum.STAFF], false),
s3ClientMiddleware,
async (req: Request, res: Response) => {
const userId: string = req.params.USERID;
Expand Down

0 comments on commit 7ac0a43

Please sign in to comment.