Handle MFA error in MFA screen (#4313)
Co-authored-by: Miguel Alatzar <this.migbot@gmail.com>
This commit is contained in:
parent
7cf4084fe5
commit
1389e4f7f7
4 changed files with 6 additions and 25 deletions
|
|
@ -25,7 +25,6 @@ import FormattedText from '@components/formatted_text';
|
|||
import {paddingHorizontal as padding} from '@components/safe_area_view/iphone_x_spacing';
|
||||
import StatusBar from '@components/status_bar';
|
||||
import {t} from '@utils/i18n';
|
||||
import {setMfaPreflightDone, getMfaPreflightDone} from '@utils/security';
|
||||
import {preventDoubleTap} from '@utils/tap';
|
||||
import {changeOpacity} from '@utils/theme';
|
||||
import tracker from '@utils/time_tracker';
|
||||
|
|
@ -68,7 +67,6 @@ export default class Login extends PureComponent {
|
|||
componentDidMount() {
|
||||
Dimensions.addEventListener('change', this.orientationDidChange);
|
||||
|
||||
setMfaPreflightDone(false);
|
||||
this.setEmmUsernameIfAvailable();
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +90,7 @@ export default class Login extends PureComponent {
|
|||
const loginId = this.loginId;
|
||||
const password = this.password;
|
||||
|
||||
goToScreen(screen, title, {onMfaComplete: this.checkLoginResponse, goToChannel: this.goToChannel, loginId, password});
|
||||
goToScreen(screen, title, {goToChannel: this.goToChannel, loginId, password});
|
||||
};
|
||||
|
||||
blur = () => {
|
||||
|
|
@ -182,9 +180,6 @@ export default class Login extends PureComponent {
|
|||
if (!errorId) {
|
||||
return error.message;
|
||||
}
|
||||
if (mfaExpectedErrors.includes(errorId) && !getMfaPreflightDone()) {
|
||||
return null;
|
||||
}
|
||||
if (
|
||||
errorId === 'store.sql_user.get_for_login.app_error' ||
|
||||
errorId === 'ent.ldap.do_login.user_not_registered.app_error'
|
||||
|
|
|
|||
|
|
@ -94,7 +94,6 @@ describe('Login', () => {
|
|||
'Multi-factor Authentication',
|
||||
{
|
||||
goToChannel: wrapper.instance().goToChannel,
|
||||
onMfaComplete: wrapper.instance().checkLoginResponse,
|
||||
loginId,
|
||||
password,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -15,14 +15,12 @@ import {
|
|||
} from 'react-native';
|
||||
import Button from 'react-native-button';
|
||||
|
||||
import {popTopScreen} from '@actions/navigation';
|
||||
import ErrorText from '@components/error_text';
|
||||
import FormattedText from '@components/formatted_text';
|
||||
import StatusBar from '@components/status_bar';
|
||||
import TextInputWithLocalizedPlaceholder from '@components/text_input_with_localized_placeholder';
|
||||
import {t} from '@utils/i18n';
|
||||
import {preventDoubleTap} from '@utils/tap';
|
||||
import {setMfaPreflightDone} from '@utils/security';
|
||||
|
||||
import {GlobalStyles} from 'app/styles';
|
||||
|
||||
|
|
@ -34,7 +32,6 @@ export default class Mfa extends PureComponent {
|
|||
goToChannel: PropTypes.func.isRequired,
|
||||
loginId: PropTypes.string.isRequired,
|
||||
password: PropTypes.string.isRequired,
|
||||
onMfaComplete: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
|
|
@ -79,7 +76,7 @@ export default class Mfa extends PureComponent {
|
|||
};
|
||||
|
||||
submit = preventDoubleTap(() => {
|
||||
const {actions, goToChannel, loginId, password, onMfaComplete} = this.props;
|
||||
const {actions, goToChannel, loginId, password} = this.props;
|
||||
const {token} = this.state;
|
||||
|
||||
Keyboard.dismiss();
|
||||
|
|
@ -94,16 +91,16 @@ export default class Mfa extends PureComponent {
|
|||
});
|
||||
return;
|
||||
}
|
||||
setMfaPreflightDone(true);
|
||||
|
||||
this.setState({isLoading: true});
|
||||
actions.login(loginId, password, token).then((result) => {
|
||||
this.setState({isLoading: false});
|
||||
if (onMfaComplete(result)) {
|
||||
goToChannel();
|
||||
if (result.error) {
|
||||
this.setState({error: result.error});
|
||||
return;
|
||||
}
|
||||
|
||||
popTopScreen();
|
||||
goToChannel();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -4,16 +4,6 @@
|
|||
import {Client4} from '@mm-redux/client';
|
||||
import CookieManager from '@react-native-community/cookies';
|
||||
|
||||
let mfaPreflightDone = false;
|
||||
|
||||
export function setMfaPreflightDone(state) {
|
||||
mfaPreflightDone = state;
|
||||
}
|
||||
|
||||
export function getMfaPreflightDone() {
|
||||
return mfaPreflightDone;
|
||||
}
|
||||
|
||||
export function setCSRFFromCookie(url) {
|
||||
return new Promise((resolve) => {
|
||||
CookieManager.get(url, false).then((cookies) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue