Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The one with real people in the backend! - v1.0.6 #197

Merged
merged 6 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/api/preferences/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion functions/import_tickets/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
16 changes: 7 additions & 9 deletions lib/authorise.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)})
})
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "congress-system",
"version": "0.3.1",
"version": "1.0.6",
"private": true,
"license": "Contact Adam & Connor for details",
"scripts": {
Expand Down
Loading