Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Benricheson101 committed Nov 13, 2024
1 parent 4d17845 commit f6c4282
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
7 changes: 5 additions & 2 deletions src/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ const {Client} = pg;

const CHECK_IN_CODE_LENGTH = 6;
const makeid = () => {
const nr = randomInt(10 ** (CHECK_IN_CODE_LENGTH - 2), 10 ** (CHECK_IN_CODE_LENGTH - 1) - 1);
const nr = randomInt(
10 ** (CHECK_IN_CODE_LENGTH - 2),
10 ** (CHECK_IN_CODE_LENGTH - 1) - 1
);
const l = toLuhn(nr).toString().padStart(CHECK_IN_CODE_LENGTH, '0');
console.log('random number:', nr, l);
return l;
Expand Down Expand Up @@ -395,7 +398,7 @@ export class Database {
ON c.id = d.club_id
WHERE d.qr_token = $1::text
`,
[qrToken],
[qrToken]
);

return res.rows?.[0];
Expand Down
22 changes: 2 additions & 20 deletions src/qr.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isValidLuhn } from '@benricheson101/util';
import {isValidLuhn} from '@benricheson101/util';
import jwt from 'jsonwebtoken';

/**
Expand Down Expand Up @@ -35,24 +35,6 @@ export class QRManager {
const qRL = `${this.#baseURL}/check-in?code=${qrToken}`;

return qRL;
//return jwt.sign(
// {
// cdID: clubDay.id,
//
// // not valid before - start time
// nbf: Math.round(clubDay.startsAt.getTime() / 1_000),
//
// // expires at - end time
// exp: Math.round(clubDay.endsAt.getTime() / 1_000),
//
// // issued at - current time
// iat: Math.round(Date.now() / 1_000),
// },
// this.#jwtSecret,
// {
// algorithm: 'HS256',
// }
//);
}

async verifyQRToken(token) {
Expand All @@ -63,7 +45,7 @@ export class QRManager {
//if the time is not valid return fasle
//if all is good return an obejct with the field cdID being the internal id of the clubday
if (!isValidLuhn(Number(token))) {
console.log('invalid luhn', {token})
console.log('invalid luhn', {token});
return false;
}

Expand Down

0 comments on commit f6c4282

Please sign in to comment.