Skip to content

Commit

Permalink
Add organiser role to volunteer routes (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
ducomputingsociety authored Oct 30, 2024
2 parents 9f6155e + a29060b commit 0b6b6cd
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion server/config/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export default {
redirectUri: "http://guilds.durhack-dev.com/api/discord/redirect",
botToken: "yourDiscordBotTokenHere",
guildID: "yourDiscordGuildIDHere",
inviteLink: "https://discord.gg/xyz",
teamsParentChannel: "yourTeamsParentChannelIdHere",
},
jsonwebtoken: {
Expand Down
1 change: 1 addition & 0 deletions server/src/common/model-enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export enum UserRole {
sponsor = "/sponsors",
volunteer = "/volunteers",
admin = "/admins",
organiser = "/organisers",
}

export enum Ethnicity {
Expand Down
1 change: 0 additions & 1 deletion server/src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export const discordOptionsSchema = z.object({
redirectUri: z.string().url(),
botToken: z.string(),
guildID: z.string(),
inviteLink: z.string(),
teamsParentChannel: z.string(),
})

Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/areas/area-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { prisma } from "@server/database"
import type { Middleware, Request, Response } from "@server/types"

class AreaHandlers {
@requireUserHasOne(UserRole.admin, UserRole.sponsor, UserRole.volunteer)
@requireUserHasOne(UserRole.admin, UserRole.sponsor, UserRole.volunteer, UserRole.organiser)
getAreasList(): Middleware {
return async (_request: Request, response: Response): Promise<void> => {
const result = await prisma.guild.findMany({
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/auth/auth-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AuthHandlers {
}

if (
request.userProfile.groups.some((userRole) => userRole === UserRole.admin || userRole === UserRole.volunteer)
request.userProfile.groups.some((userRole) => userRole === UserRole.admin || userRole === UserRole.volunteer || userRole === UserRole.organiser)
) {
await response.redirect("/volunteer")
return
Expand Down
6 changes: 3 additions & 3 deletions server/src/routes/qr-codes/qr-codes-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class QRCodesHandlers {
};
}

@requireUserHasOne(UserRole.admin, UserRole.volunteer, UserRole.sponsor)
@requireUserHasOne(UserRole.admin, UserRole.volunteer, UserRole.sponsor, UserRole.organiser)
useChallenge(): Middleware {
return async (request: Request, response: Response) => {
const { challenge_id } = response.locals;
Expand Down Expand Up @@ -134,7 +134,7 @@ class QRCodesHandlers {
state: z.boolean().optional(),
});

@requireUserHasOne(UserRole.admin, UserRole.volunteer, UserRole.sponsor)
@requireUserHasOne(UserRole.admin, UserRole.volunteer, UserRole.sponsor, UserRole.organiser)
patchQRCodeDetails(): Middleware {
return async (request: Request, response: Response): Promise<void> => {
const { qr_code_id } = response.locals;
Expand Down Expand Up @@ -223,7 +223,7 @@ class QRCodesHandlers {
.optional(),
});

@requireUserHasOne(UserRole.admin, UserRole.volunteer, UserRole.sponsor)
@requireUserHasOne(UserRole.admin, UserRole.volunteer, UserRole.sponsor, UserRole.organiser)
getChallengeList(): Middleware {
return async (request: Request, response: Response): Promise<void> => {
const query = QRCodesHandlers.challengeListQuerySchema.parse(request.query);
Expand Down
4 changes: 2 additions & 2 deletions server/src/routes/teams/teams-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class TeamsHandlers {
}
}

@requireUserHasOne(UserRole.admin, UserRole.sponsor, UserRole.volunteer)
@requireUserHasOne(UserRole.admin, UserRole.sponsor, UserRole.volunteer, UserRole.organiser)
listTeamsAsAdmin(): Middleware {
return async (request: Request, response: Response) => {
const result = await prisma.$queryRawTyped(getTeamsWithEverything())
Expand Down Expand Up @@ -100,7 +100,7 @@ class TeamsHandlers {
area_code: z.number(),
})

@requireUserHasOne(UserRole.admin, UserRole.sponsor, UserRole.volunteer)
@requireUserHasOne(UserRole.admin, UserRole.sponsor, UserRole.volunteer, UserRole.organiser)
patchTeamAsAdmin(): Middleware {
return async (request: Request, response: Response) => {
const { team_id } = response.locals
Expand Down

0 comments on commit 0b6b6cd

Please sign in to comment.