diff --git a/src/constants.ts b/src/constants.ts index e249d5d3..f36e8508 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -12,22 +12,18 @@ abstract class Constants { static readonly INTERNAL_ERROR: number = 500; // URLs - private static readonly ADMIN_DEVICE: string = "admin"; - private static readonly ADMIN_REDIRECT: string = "https://admin.hackillinois.org/auth/"; + static readonly ADMIN_DEVICE: string = "admin"; + static readonly DEV_DEVICE: string = "dev"; + static readonly WEB_DEVICE: string = "web"; + static readonly IOS_DEVICE: string = "ios"; + static readonly ANDROID_DEVICE: string = "android"; + static readonly DEFAULT_DEVICE: string = Constants.WEB_DEVICE; - private static readonly DEV_DEVICE: string = "dev"; + private static readonly ADMIN_REDIRECT: string = "https://admin.hackillinois.org/auth/"; private static readonly DEV_REDIRECT: string = "https://adonix.hackillinois.org/auth/dev/"; - - private static readonly WEB_DEVICE: string = "web"; private static readonly WEB_REDIRECT: string = "https://www.hackillinois.org/auth/"; - - private static readonly IOS_DEVICE: string = "ios"; private static readonly IOS_REDIRECT: string = "hackillinois://login/"; - - private static readonly ANDROID_DEVICE: string = "android"; private static readonly ANDROID_REDIRECT: string = "hackillinois://login/"; - - static readonly DEFAULT_DEVICE: string = this.WEB_DEVICE; static readonly DEFAULT_REDIRECT: string = this.WEB_REDIRECT; static readonly REDIRECT_MAPPINGS: Map = new Map([ @@ -35,7 +31,7 @@ abstract class Constants { [this.WEB_DEVICE, this.WEB_REDIRECT], [this.IOS_DEVICE, this.IOS_REDIRECT], [this.ANDROID_DEVICE, this.ANDROID_REDIRECT], - [this.DEFAULT_DEVICE, this.DEFAULT_REDIRECT], + [Constants.DEFAULT_DEVICE, this.DEFAULT_REDIRECT], [this.DEV_DEVICE, this.DEV_REDIRECT], ]); @@ -48,7 +44,7 @@ abstract class Constants { static readonly SYSTEM_ADMIN_LIST: string[] = (process.env.SYSTEM_ADMINS ?? "").split(","); - static readonly DEFAULT_JWT_OFFSET: string = "48h"; + static readonly DEFAULT_JWT_OFFSET: string = "24h"; // Constants for general usage static readonly ZERO: number = 0; diff --git a/src/services/auth/auth-lib.ts b/src/services/auth/auth-lib.ts index f61318f1..6c51dea3 100644 --- a/src/services/auth/auth-lib.ts +++ b/src/services/auth/auth-lib.ts @@ -107,7 +107,7 @@ export async function getJwtPayloadFromDB(targetUser: string): Promise { // Return the same payload, but with a shorter expiration time const payload: JwtPayload = res.locals.payload as JwtPayload; - const token: string = generateJwtToken(payload, "20s"); + const token: string = generateJwtToken(payload, false, "20s"); const uri: string = `hackillinois://user?userToken=${token}`; res.status(Constants.SUCCESS).send({ id: payload.id, qrInfo: uri }); }); @@ -84,7 +84,7 @@ userRouter.get("/qr/:USERID", strongJwtVerification, async (req: Request, res: R } // Generate the token - const token: string = generateJwtToken(newPayload, "20s"); + const token: string = generateJwtToken(newPayload, false, "20s"); const uri: string = `hackillinois://user?userToken=${token}`; return res.status(Constants.SUCCESS).send({ id: payload.id, qrInfo: uri }); });