[FIX] Login TOTP Compatibility to older servers (#2018)

* [FIX] Login TOTP Compatibility to older servers

* [FIX] Android crashes if use double negation

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Djorkaeff Alexandre 2020-04-13 10:25:31 -03:00 committed by GitHub
parent acf70790cd
commit 2b3ccf4df5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -48,6 +48,7 @@ const TwoFactor = React.memo(({ theme, split }) => {
useDeepCompareEffect(() => {
if (!_.isEmpty(data)) {
setCode('');
setVisible(true);
} else {
setVisible(false);
@ -94,7 +95,7 @@ const TwoFactor = React.memo(({ theme, split }) => {
<View style={styles.container}>
<View style={[styles.content, split && [sharedStyles.modal, sharedStyles.modalFormSheet], { backgroundColor: themes[theme].backgroundColor }]}>
<Text style={[styles.title, { color }]}>{I18n.t(method?.title || 'Two_Factor_Authentication')}</Text>
<Text style={[styles.subtitle, { color }]}>{I18n.t(method?.text)}</Text>
{method?.text ? <Text style={[styles.subtitle, { color }]}>{I18n.t(method.text)}</Text> : null}
<TextInput
value={code}
theme={theme}

View File

@ -15,11 +15,12 @@ export default StyleSheet.create({
},
title: {
fontSize: 14,
paddingBottom: 8,
...sharedStyles.textBold
},
subtitle: {
fontSize: 14,
paddingVertical: 8,
paddingBottom: 8,
...sharedStyles.textRegular,
...sharedStyles.textAlignCenter
},

View File

@ -337,8 +337,8 @@ const RocketChat = {
if (e.data?.error && (e.data.error === 'totp-required' || e.data.error === 'totp-invalid')) {
const { details } = e.data;
try {
await twoFactor({ method: details?.method, invalid: e.data.error === 'totp-invalid' });
return resolve(this.loginTOTP(params));
const code = await twoFactor({ method: details?.method || 'totp', invalid: e.data.error === 'totp-invalid' });
return resolve(this.loginTOTP({ ...params, code: code?.twoFactorCode }));
} catch {
// twoFactor was canceled
return reject();