[CHORE] Force normalized params for 2FA (#2683)

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Djorkaeff Alexandre 2020-12-01 09:54:10 -03:00 committed by GitHub
parent 7b4be8bddf
commit 3bc8161bc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -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