Skip to content

Support validated links coming from e.com#5387

Closed
iwiznia wants to merge 9 commits into
mainfrom
ionatan_link_fromolddot
Closed

Support validated links coming from e.com#5387
iwiznia wants to merge 9 commits into
mainfrom
ionatan_link_fromolddot

Conversation

@iwiznia

@iwiznia iwiznia commented Sep 21, 2021

Copy link
Copy Markdown
Contributor

Please review!

CC: @cead22, @tgolen, @marcaaron, @Luke9389

Details

Fixed Issues

https://github.com/Expensify/Expensify/issues/177739

Tests

See https://github.com/Expensify/Web-Expensify/pull/31977

QA Steps

  1. Log into an account on NewDot Expensify, create a Workspace if you don't already have one using the + on the bottom right.
  2. Log out of NewDot and then log into that same account on OldDot and go to Settings -> Policy and find your Workspace there. It should have a card icon like these:
    image
  3. Click on its name and verify it opens a new tab, automatically logs you in, and brings you to the workspace settings page:
    image

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Included above

@iwiznia iwiznia self-assigned this Sep 21, 2021
@TomatoToaster TomatoToaster self-assigned this Sep 21, 2021
@TomatoToaster

Copy link
Copy Markdown
Contributor

PR for adding workspace/new is ready here: https://github.com/Expensify/App/pull/5396/files. This could be its own PR and I could add testing steps for it.

Or I could merge it with this one which might help test that this PR works. I'm also trying to make sure urls where we do exitTo=workspace/<workspaceID>/card also works.

I'm going to work on the Web-Expensify part right now.

Comment thread src/libs/Navigation/linkingConfig.js Outdated
[SCREENS.LOGIN_WITH_VALIDATE_CODE_2FA_NEW_WORKSPACE]: ROUTES.LOGIN_WITH_VALIDATE_CODE_2FA_NEW_WORKSPACE,
[SCREENS.LOGIN_WITH_VALIDATE_CODE_WORKSPACE_CARD]: ROUTES.LOGIN_WITH_VALIDATE_CODE_WORKSPACE_CARD,
[SCREENS.LOGIN_WITH_VALIDATE_CODE_2FA_WORKSPACE_CARD]: ROUTES.LOGIN_WITH_VALIDATE_CODE_2FA_WORKSPACE_CARD,
LogInWithShortLivedToken: ROUTES.LOGIN_WITH_SHORTLIVED_AUTHTOKEN,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we put LogInWithShortLivedToken in a const under SCREEN?

Comment thread src/libs/actions/Session.js Outdated
function signInWithShortLivedToken(accountID, email, shortLivedToken, encryptedAuthToken, exitTo) {
Onyx.merge(ONYXKEYS.ACCOUNT, {...CONST.DEFAULT_ACCOUNT_DATA, loading: true});

createTemporaryLogin(shortLivedToken, encryptedAuthToken).then((response) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is createTemporaryLogin missing the email param? Maybe it's not really needed in API.CreateLogin, but NAB we don't have to fix that in this PR

@cead22 cead22 requested a review from marcaaron September 21, 2021 23:50
@TomatoToaster TomatoToaster marked this pull request as ready for review September 22, 2021 00:01
@TomatoToaster TomatoToaster requested a review from a team as a code owner September 22, 2021 00:01
@MelvinBot MelvinBot requested review from Julesssss and removed request for a team September 22, 2021 00:01

@marcaaron marcaaron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving a few initial comments.

Comment thread src/libs/API.js
Comment thread src/libs/API.js
partnerPassword: CONFIG.EXPENSIFY.PARTNER_PASSWORD,
partnerUserID: credentials.autoGeneratedLogin,
partnerUserSecret: credentials.autoGeneratedPassword,
authToken,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not really getting why the authToken is included when calling reauthenticate()? Maybe we could use a comment here or something. My previous understanding of this method is that we will use the credentials to get a new authToken not call it with the one already in storage or the last one we got when we called reauthenticate().

Comment thread src/libs/actions/Session.js Outdated
function signInWithShortLivedToken(accountID, email, shortLivedToken) {
Onyx.merge(ONYXKEYS.ACCOUNT, {...CONST.DEFAULT_ACCOUNT_DATA, loading: true});

createTemporaryLogin(shortLivedToken).then((response) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the fact that we are not passing an email to createTemporaryLogin going to create any sort of problem?

* @param {String} email
* @return {Promise}
*/
function createTemporaryLogin(authToken, encryptedAuthToken, email) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're making encryptedAuthToken and email optional we should update the docs

const exitTo = decodeURIComponent(lodashGet(this.props.route.params, 'exitTo', ''));

// If the user is revisiting the component authenticated or they were already logged into the right account, we simply redirect them to the exitTo
if (this.props.session.authToken && email === this.props.session.email) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB, it's good that we are checking if the email is the same. But it doesn't look like we are handling the case where it's not. We might not need to worry about this just yet, but feels like bad things would happen if you tried to sign in one user while still logged in as another.

Comment thread src/libs/actions/Session.js Outdated
email,
});
if (response.jsonCode === 200) {
getUserDetails();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh hmm why are we doing this? It should happen when we set the authToken no?

User.getUserDetails();
User.getBetas();

Comment thread src/libs/actions/Session.js Outdated
});
}

function signInWithShortLivedToken(accountID, email, shortLivedToken) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Don't we need to call authenticate with the short lived token before creating a login?
  • We're calling signInWithShortLivedToken(shortLivedToken) and not passing encrypted auth token, that means it'll be set to undefined in setSuccessfulSignInData right?

import Navigation from '../libs/Navigation/Navigation';

const propTypes = {
/** The accountID and validateCode are passed via the URL */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right or outdated?

Comment thread src/pages/LogInWithShortLivedTokenPage.js
Comment thread src/SCREENS.js
HOME: 'Home',
LOADING: 'Loading',
REPORT: 'Report',
LOG_IN_WITH_SHORT_LIVED_TOKEN: 'LogInWithShortLivedToken',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we align SHORTLIVED and SHORT_LIVED to help make this searchable?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh true. Yes, I will once I figure out which PR we should be using.

@iwiznia

iwiznia commented Sep 22, 2021

Copy link
Copy Markdown
Contributor Author

This PR was replaced by #5396

@iwiznia iwiznia closed this Sep 22, 2021
@roryabraham roryabraham deleted the ionatan_link_fromolddot branch June 8, 2023 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants