From 3bc8161bc8828dc205a15764b5c918b636eb6472 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Tue, 1 Dec 2020 09:54:10 -0300 Subject: [PATCH] [CHORE] Force normalized params for 2FA (#2683) Co-authored-by: Diego Mello --- app/lib/rocketchat.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 6c27b62d..182fd856 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -462,6 +462,15 @@ const RocketChat = { try { reduxStore.dispatch(setUser({ username: params.user || params.username })); const code = await twoFactor({ method: details?.method || 'totp', invalid: e.data.error === 'totp-invalid' }); + + // Force normalized params for 2FA starting RC 3.9.0. + const serverVersion = reduxStore.getState().server.version; + if (serverVersion && semver.gte(semver.coerce(serverVersion), '3.9.0')) { + const user = params.user ?? params.username; + const password = params.password ?? params.ldapPass ?? params.crowdPassword; + params = { user, password }; + } + return resolve(this.loginTOTP({ ...params, code: code?.twoFactorCode }, loginEmailPassword)); } catch { // twoFactor was canceled