diff --git a/app/api/preferences/route.ts b/app/api/preferences/route.ts index 83ffcd32..3e0c9804 100644 --- a/app/api/preferences/route.ts +++ b/app/api/preferences/route.ts @@ -12,8 +12,8 @@ export async function POST(request: Request) { console.log("courseInfo", courseInfo) console.log("Diet",dietChoices) const apiRequestBody = { - ticket_number: ticket.value, - email: email.value, + ticket_number: ticket.value.trim(), + email: email.value.trim(), preferences: { choices: courseInfo, dietary_requirements: { diff --git a/functions/import_tickets/lambda_function.py b/functions/import_tickets/lambda_function.py index 54df3c14..1047621d 100644 --- a/functions/import_tickets/lambda_function.py +++ b/functions/import_tickets/lambda_function.py @@ -77,7 +77,7 @@ def lambda_handler(event, context): options = data['options'] for attendee in attendees: - line_items = get_line_items(attendee['passes'], attendee['unit_amount']*100) + line_items = get_line_items(attendee['passes'], attendee['unit_amount']) ticket_number = str(attendee['ticket_number']) if attendee['ticket_number'] is not None else str(get_ticket_number(attendee['email'], attendee['student_ticket'])) purchased_at = int(time.mktime(datetime.strptime(attendee['purchased_at'], '%Y-%m-%dT%H:%M:%S.000Z').timetuple())) input = { diff --git a/lib/authorise.ts b/lib/authorise.ts index 2f8599a9..14bdb493 100644 --- a/lib/authorise.ts +++ b/lib/authorise.ts @@ -1,17 +1,13 @@ const superuser = "superadmin" + +// These control access to various admin functionalities. Either direct path without querystring or regular expressions const grantUsage = { - "all-admins": ["/admin"], + "all-admins": ["/admin"], // Everyone gets this set "developer": ["#","/admin/users","/admin/stripe","/admin/import"], "content-manager": ['/admin/content'], "door-staff": ['/admin/ticketing','/admin/scan', '/admin/epos'], + "event-manager": ['/admin/ticketing.*'] // Everything under ticketing } -// const grantView = { -// "developer": { -// "thing": ["create","update","read","delete"], -// "otherthing": ["create","update","read","delete"] -// } -// } - export const authUsage = (user,path) => { // Check could ever be allowed to do anything @@ -21,10 +17,12 @@ export const authUsage = (user,path) => { const roles = user.publicMetadata.roles // Superuser gets set to true always if(roles.includes(superuser)) return true + // Check against all admins stuff + if(grantUsage['all-admins'].includes(pathWithoutQueryString)) return true // check through roles to see if any of them allow access to path return roles.some((role) => { if(!grantUsage[role]) return false // Roles doesn't exist in permissions - return grantUsage[role] && grantUsage[role].includes(pathWithoutQueryString) + return grantUsage[role] && grantUsage[role].some((pattern) => { return pathWithoutQueryString == pattern || new RegExp(`^${pattern}$`).test(pathWithoutQueryString)}) }) } diff --git a/package.json b/package.json index 1f0e42e4..08217896 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "congress-system", - "version": "0.3.1", + "version": "1.0.6", "private": true, "license": "Contact Adam & Connor for details", "scripts": {