[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(() => {
|
||||
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}
|
||||
|
|
|
@ -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
|
||||
},
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue