diff --git a/src/libs/actions/Session.js b/src/libs/actions/Session.js index a70ec279d3b3..2d93e508b29c 100644 --- a/src/libs/actions/Session.js +++ b/src/libs/actions/Session.js @@ -342,6 +342,16 @@ function continueSessionFromECom(accountID, validateCode, twoFactorAuthCode) { }); } +/** + * Clear the credentials and partial sign in session so the user can taken back to first Login step + */ +function clearSignInData() { + Onyx.multiSet({ + [ONYXKEYS.ACCOUNT]: null, + [ONYXKEYS.CREDENTIALS]: null, + }); +} + /** * Put any logic that needs to run when we are signed out here. This can be triggered when the current tab or another tab signs out. */ @@ -365,5 +375,6 @@ export { reopenAccount, resendValidationLink, resetPassword, + clearSignInData, cleanupSession, }; diff --git a/src/pages/signin/ChangeExpensifyLoginLink.js b/src/pages/signin/ChangeExpensifyLoginLink.js index 4fe1741e2f94..a8d3d16be345 100755 --- a/src/pages/signin/ChangeExpensifyLoginLink.js +++ b/src/pages/signin/ChangeExpensifyLoginLink.js @@ -5,11 +5,11 @@ import PropTypes from 'prop-types'; import Str from 'expensify-common/lib/str'; import Text from '../../components/Text'; import styles from '../../styles/styles'; -import redirectToSignIn from '../../libs/actions/SignInRedirect'; import themeColors from '../../styles/themes/default'; import ONYXKEYS from '../../ONYXKEYS'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import compose from '../../libs/compose'; +import {clearSignInData} from '../../libs/actions/Session'; const propTypes = { /** The credentials of the logged in person */ @@ -33,7 +33,7 @@ const ChangeExpensifyLoginLink = ({credentials, translate, toLocalPhone}) => ( redirectToSignIn()} + onPress={clearSignInData} underlayColor={themeColors.componentBG} > diff --git a/src/pages/signin/SignInPage.js b/src/pages/signin/SignInPage.js index 05bc0feb6b40..407f757c7aac 100644 --- a/src/pages/signin/SignInPage.js +++ b/src/pages/signin/SignInPage.js @@ -39,18 +39,11 @@ const propTypes = { twoFactorAuthCode: PropTypes.string, }), - /** The session of the logged in person */ - session: PropTypes.shape({ - /** Error to display when there is a session error returned */ - authToken: PropTypes.string, - }), - ...withLocalizePropTypes, }; const defaultProps = { account: {}, - session: {}, credentials: {}, }; @@ -115,6 +108,5 @@ export default compose( withOnyx({ account: {key: ONYXKEYS.ACCOUNT}, credentials: {key: ONYXKEYS.CREDENTIALS}, - session: {key: ONYXKEYS.SESSION}, }), )(SignInPage);