[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:
parent
acf70790cd
commit
2b3ccf4df5
|
@ -48,6 +48,7 @@ const TwoFactor = React.memo(({ theme, split }) => {
|
||||||
|
|
||||||
useDeepCompareEffect(() => {
|
useDeepCompareEffect(() => {
|
||||||
if (!_.isEmpty(data)) {
|
if (!_.isEmpty(data)) {
|
||||||
|
setCode('');
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
@ -94,7 +95,7 @@ const TwoFactor = React.memo(({ theme, split }) => {
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<View style={[styles.content, split && [sharedStyles.modal, sharedStyles.modalFormSheet], { backgroundColor: themes[theme].backgroundColor }]}>
|
<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.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
|
<TextInput
|
||||||
value={code}
|
value={code}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
|
|
|
@ -15,11 +15,12 @@ export default StyleSheet.create({
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
|
paddingBottom: 8,
|
||||||
...sharedStyles.textBold
|
...sharedStyles.textBold
|
||||||
},
|
},
|
||||||
subtitle: {
|
subtitle: {
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
paddingVertical: 8,
|
paddingBottom: 8,
|
||||||
...sharedStyles.textRegular,
|
...sharedStyles.textRegular,
|
||||||
...sharedStyles.textAlignCenter
|
...sharedStyles.textAlignCenter
|
||||||
},
|
},
|
||||||
|
|
|
@ -337,8 +337,8 @@ const RocketChat = {
|
||||||
if (e.data?.error && (e.data.error === 'totp-required' || e.data.error === 'totp-invalid')) {
|
if (e.data?.error && (e.data.error === 'totp-required' || e.data.error === 'totp-invalid')) {
|
||||||
const { details } = e.data;
|
const { details } = e.data;
|
||||||
try {
|
try {
|
||||||
await twoFactor({ method: details?.method, invalid: e.data.error === 'totp-invalid' });
|
const code = await twoFactor({ method: details?.method || 'totp', invalid: e.data.error === 'totp-invalid' });
|
||||||
return resolve(this.loginTOTP(params));
|
return resolve(this.loginTOTP({ ...params, code: code?.twoFactorCode }));
|
||||||
} catch {
|
} catch {
|
||||||
// twoFactor was canceled
|
// twoFactor was canceled
|
||||||
return reject();
|
return reject();
|
||||||
|
|
Loading…
Reference in New Issue