-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Darrin-Lin/Camp_2024
Camp 2024 updates
- Loading branch information
Showing
12 changed files
with
607 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { db } from "$lib/server/db"; | ||
import type { RequestHandler } from "./$types"; | ||
import { json, redirect } from "@sveltejs/kit"; | ||
import { env } from "$env/dynamic/private"; | ||
|
||
|
||
export const PATCH: RequestHandler = async ({ locals, request }) => { | ||
if (!locals.token) { | ||
console.log("Someone is trying to access admin page without token"); | ||
throw redirect(302, "/login"); | ||
} | ||
|
||
if (!env.ADMIN_EMAIL_REGEX) { | ||
console.error("ADMIN_EMAIL_REGEX is not set"); | ||
throw new Error("ADMIN_EMAIL_REGEX is not set"); | ||
} | ||
|
||
const email_regex = new RegExp(env.ADMIN_EMAIL_REGEX); | ||
if (!email_regex.test(locals.token.email)) { | ||
console.log( | ||
`${locals.token.email} is trying to access admin page which does not match ${env.ADMIN_EMAIL_REGEX}`, | ||
); | ||
throw redirect(302, "/login"); | ||
} | ||
|
||
|
||
// get email and input_status from request body | ||
const { email, input_status }: { email: string, input_status: string } = await request.json(); | ||
const now = new Date().toISOString(); | ||
await db | ||
.updateTable("Application") | ||
.set({ status: input_status, updated: now }) | ||
.where("email", "=", email) | ||
.execute(); | ||
|
||
return json({ ok: true }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { env } from "$env/dynamic/private"; | ||
import { db } from "$lib/server/db"; | ||
import { json, redirect } from "@sveltejs/kit"; | ||
import type { RequestHandler } from "./$types"; | ||
|
||
export const PATCH: RequestHandler = async ({ locals, request }) => { | ||
if (!locals.token) { | ||
console.log("Someone is trying to access admin page without token"); | ||
throw redirect(302, "/login"); | ||
} | ||
|
||
if (!env.ADMIN_EMAIL_REGEX) { | ||
console.error("ADMIN_EMAIL_REGEX is not set"); | ||
throw new Error("ADMIN_EMAIL_REGEX is not set"); | ||
} | ||
|
||
const email_regex = new RegExp(env.ADMIN_EMAIL_REGEX); | ||
if (!email_regex.test(locals.token.email)) { | ||
console.log( | ||
`${locals.token.email} is trying to access admin page which does not match ${env.ADMIN_EMAIL_REGEX}`, | ||
); | ||
throw redirect(302, "/login"); | ||
} | ||
|
||
const { email, correctness }: { email: string; correctness: string } = await request.json(); | ||
await db | ||
.updateTable("Payment") | ||
.set({ correct: correctness }) | ||
.where("email", "=", email) | ||
.execute(); | ||
console.log(`Payment correctness for ${email} is set to ${correctness}`); | ||
return json({ ok: true }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.