Skip to content

Commit

Permalink
removed admin-util
Browse files Browse the repository at this point in the history
  • Loading branch information
sdagg9 committed Jun 10, 2024
1 parent b43555f commit 97b2875
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/services/admin/admin-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Database } from "../../database";
import RoleChecker from "../../middleware/role-checker";
import { Role } from "../auth/auth-models";
import dotenv from "dotenv";

Check failure on line 6 in src/services/admin/admin-router.ts

View workflow job for this annotation

GitHub Actions / lint

'dotenv' is defined but never used

Check failure on line 6 in src/services/admin/admin-router.ts

View workflow job for this annotation

GitHub Actions / build

'dotenv' is declared but its value is never read.
import { validateQrHash } from "./admin-utils";
import { validateQrHash } from "../attendees/attendees-utils";


Check failure on line 9 in src/services/admin/admin-router.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎`
const adminRouter = Router();
Expand Down
31 changes: 0 additions & 31 deletions src/services/admin/admin-utils.ts

This file was deleted.

13 changes: 13 additions & 0 deletions src/services/attendees/attendees-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,16 @@ export function generateQrHash(userId: string, expTime: number) {

return `${hashStr}#${expTime}#${userId}`;
}

export function validateQrHash(qrCode: string) {
const parts = qrCode.split("#");
const userId = parts[2];
const expTime = parseInt(parts[1]);
const generatedHash = generateQrHash(userId, expTime);

if (generatedHash.split("#")[0] !== parts[0]) {
throw new Error("Invalid QR code");
}

return { userId, expTime };
}

Check failure on line 31 in src/services/attendees/attendees-utils.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `⏎`

0 comments on commit 97b2875

Please sign in to comment.