diff --git a/src/libs/API.js b/src/libs/API.js index 8d12b62cf2e..ff6d69e025b 100644 --- a/src/libs/API.js +++ b/src/libs/API.js @@ -273,7 +273,6 @@ function reauthenticate(command = '') { partnerPassword: CONFIG.EXPENSIFY.PARTNER_PASSWORD, partnerUserID: credentials.autoGeneratedLogin, partnerUserSecret: credentials.autoGeneratedPassword, - authToken, }) .then((response) => { // If authentication fails throw so that we hit diff --git a/src/libs/actions/Session.js b/src/libs/actions/Session.js index 2982e61f3d1..310c6a013c8 100644 --- a/src/libs/actions/Session.js +++ b/src/libs/actions/Session.js @@ -165,11 +165,10 @@ function fetchAccountDetails(login) { * re-authenticating after an authToken expires. * * @param {String} authToken - * @param {String} encryptedAuthToken – Not required for the CreateLogin API call, but passed to setSuccessfulSignInData * @param {String} email * @return {Promise} */ -function createTemporaryLogin(authToken, encryptedAuthToken, email) { +function createTemporaryLogin(authToken, email) { const autoGeneratedLogin = Str.guid('expensify.cash-'); const autoGeneratedPassword = Str.guid(); @@ -182,13 +181,14 @@ function createTemporaryLogin(authToken, encryptedAuthToken, email) { doNotRetry: true, forceNetworkRequest: true, email, + includeEncryptedAuthToken: true, }) .then((createLoginResponse) => { if (createLoginResponse.jsonCode !== 200) { throw new Error(createLoginResponse.message); } - setSuccessfulSignInData({...createLoginResponse, encryptedAuthToken}); + setSuccessfulSignInData(createLoginResponse); // If we have an old generated login for some reason // we should delete it before storing the new details @@ -237,9 +237,8 @@ function signIn(password, twoFactorAuthCode) { twoFactorAuthCode, email: credentials.login, }) - .then((authenticateResponse) => { - const {authToken, encryptedAuthToken, email} = authenticateResponse; - createTemporaryLogin(authToken, encryptedAuthToken, email); + .then(({authToken, email}) => { + createTemporaryLogin(authToken, email); }) .catch((error) => { Onyx.merge(ONYXKEYS.ACCOUNT, {error: translateLocal(error.message), loading: false}); @@ -252,14 +251,12 @@ function signIn(password, twoFactorAuthCode) { * @param {String} accountID * @param {String} email * @param {String} shortLivedToken - * @param {string} encryptedAuthToken */ -function signInWithShortLivedToken(accountID, email, shortLivedToken, encryptedAuthToken) { +function signInWithShortLivedToken(accountID, email, shortLivedToken) { Onyx.merge(ONYXKEYS.ACCOUNT, {...CONST.DEFAULT_ACCOUNT_DATA, loading: true}); - createTemporaryLogin(shortLivedToken, encryptedAuthToken, email).then((response) => { + createTemporaryLogin(shortLivedToken, email).then((response) => { Onyx.merge(ONYXKEYS.SESSION, { - authToken: shortLivedToken, accountID, email, }); @@ -305,7 +302,7 @@ function setPassword(password, validateCode, accountID) { }) .then((response) => { if (response.jsonCode === 200) { - createTemporaryLogin(response.authToken, response.encryptedAuthToken, response.email); + createTemporaryLogin(response.authToken, response.email); return; } diff --git a/src/pages/LogInWithShortLivedTokenPage.js b/src/pages/LogInWithShortLivedTokenPage.js index da341feb780..6fb1d3fde8b 100644 --- a/src/pages/LogInWithShortLivedTokenPage.js +++ b/src/pages/LogInWithShortLivedTokenPage.js @@ -57,14 +57,13 @@ class LogInWithShortLivedTokenPage extends Component { const accountID = parseInt(lodashGet(this.props.route.params, 'accountID', ''), 10); const email = lodashGet(this.props.route.params, 'email', ''); const shortLivedToken = lodashGet(this.props.route.params, 'shortLivedToken', ''); - const encryptedAuthToken = lodashGet(this.props.route.params, 'encryptedAuthToken', ''); // If the user is revisiting the component authenticated with the right account, we don't need to do anything, the componentWillUpdate when betas are loaded and redirect if (this.props.session.authToken && email === this.props.session.email) { return; } - signInWithShortLivedToken(accountID, email, shortLivedToken, encryptedAuthToken); + signInWithShortLivedToken(accountID, email, shortLivedToken); } componentDidUpdate() {