From 1e541de7db2e6704095e510b220a437dba1b940a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 5 Aug 2022 08:11:32 -0400 Subject: [PATCH] fix: don't crash if req.body.username is not string Error: req.body.username.trim is not a function File: authenticationController.login (/usr/src/app/src/controllers/authentication.js:247:40) --- src/controllers/authentication.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index cf2d6a55a4..b97b0ca8c2 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -244,7 +244,7 @@ authenticationController.login = async (req, res, next) => { } const loginWith = meta.config.allowLoginWith || 'username-email'; - req.body.username = req.body.username.trim(); + req.body.username = String(req.body.username).trim(); const errorHandler = res.locals.noScriptErrors || helpers.noScriptErrors; try { await plugins.hooks.fire('filter:login.check', { req: req, res: res, userData: req.body });