Fixed 2FA server crash.

Ylian Saint-Hilaire committed Sep 17, 2020 at 10:42 UTC 92b00d29a207184a0d18563ea36f0675ed479d4b
1 file changed +1 -1
webserver.js
+1 -1
@@ -724,7 +724,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
724 if ((typeof domain.passwordrequirements == 'object') && (domain.passwordrequirements.sms2factor == false)) { otpsms = false; }
725
726 // Check 2FA login cookie
727 - if (token.startsWith('cookie=')) {
727 + if ((token != null) && (token.startsWith('cookie='))) {
728 var twoFactorCookie = obj.parent.decodeCookie(decodeURIComponent(token.substring(7)), obj.parent.loginCookieEncryptionKey, (30 * 24 * 60)); // If the cookies does not have an expire feild, assume 30 day timeout.
729 if ((twoFactorCookie != null) && ((obj.args.cookieipcheck === false) || (twoFactorCookie.ip == null) || (twoFactorCookie.ip === req.clientIp)) && (twoFactorCookie.userid == user._id)) { func(true); return; }
730 }