From 9f833d32a27eb61ca94569891c1965bb77bacf5d Mon Sep 17 00:00:00 2001 From: Tzahi12345 Date: Sat, 1 Apr 2023 18:31:45 -0400 Subject: [PATCH] Fixed an issue where JWT_EXPIRATION was sometimes a string causing a crash (#813) --- backend/authentication/auth.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/authentication/auth.js b/backend/authentication/auth.js index 92740d1..30e1e02 100644 --- a/backend/authentication/auth.js +++ b/backend/authentication/auth.js @@ -33,7 +33,14 @@ exports.initialize = function () { saltRounds = 10; + // Sometimes this value is not properly typed: https://github.com/Tzahi12345/YoutubeDL-Material/issues/813 JWT_EXPIRATION = config_api.getConfigItem('ytdl_jwt_expiration'); + if (!(+JWT_EXPIRATION)) { + logger.warn(`JWT expiration value improperly set to ${JWT_EXPIRATION}, auto setting to 1 day.`); + JWT_EXPIRATION = 86400; + } else { + JWT_EXPIRATION = +JWT_EXPIRATION; + } SERVER_SECRET = null; if (db_api.users_db.get('jwt_secret').value()) {