-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HOLD for Payment 2023-12-21] [$500] App is calling OpenApp instead of ReconnectApp when reloading the page #32590
Comments
Triggered auto assignment to @sonialiap ( |
Job added to Upwork: https://www.upwork.com/jobs/~01b01257e6ae73d2aa |
Bug0 Triage Checklist (Main S/O)
|
Triggered auto assignment to Contributor-plus team member for initial proposal review - @fedirjh ( |
This comment was marked as outdated.
This comment was marked as outdated.
ProposalPlease re-state the problem that we are trying to solve in this issue.App is calling openApp instead of reconnectApp on reload What is the root cause of that problem?On AuthScreen, app is thinking that it is transitioning from login as a new user while it shouldn't. Lines 25 to 26 in deda6ae
What changes do you think we should make in order to solve the problem?On transition, email params is in the URL address bar, we can simply check if it doesn't exist, than it should not be treated as a transition. Change this line here: Lines 16 to 18 in deda6ae
to: if (!paramsEmail || paramsEmail === sessionEmail) {
return false;
} What alternative solutions did you explore? (Optional)N/A |
ProposalPlease re-state the problem that we are trying to solve in this issue.
What is the root cause of that problem?Disclaimer: There will be a lot of text, but please try to keep up with my thoughts as I tried a simpler solution, but it looks like a workaround, and while investigating, I found a deeper issue with the session handling. The RCA is long, the solution will be simple. This particular issue comes from #29013, where the author had an intention to fix the case when there was an attempt to log in to different accounts during one session:
For some reason, it was decided to use the We already were checking the Now to the actual investigation of the
|
// To tell if the user logged in during this session we will check the value of session.authToken once when the app's JS inits. When the user logs out | |
// we can reset this flag so that it can be updated again. | |
Onyx.connect({ | |
key: ONYXKEYS.SESSION, | |
callback: (session) => { | |
if (loggedInDuringSession) { | |
return; | |
} | |
if (session?.authToken) { | |
loggedInDuringSession = false; | |
} else { | |
loggedInDuringSession = true; | |
} | |
}, | |
}); |
However, when logging in as a suspended user, and clicking "back", we explicitly call redirectToSignIn
, which resets Onyx data and the loggedInDuringSession
value:
onPress={() => redirectToSignIn()} |
App/src/libs/actions/SignInRedirect.ts
Lines 76 to 84 in 5d45f0f
function redirectToSignIn(errorMessage?: string) { | |
MainQueue.clear(); | |
HttpUtils.cancelPendingRequests(); | |
PersistedRequests.clear(); | |
NetworkConnection.clearReconnectionCallbacks(); | |
clearStorageAndRedirect(errorMessage); | |
resetHomeRouteParams(); | |
SessionUtils.resetDidUserLogInDuringSession(); | |
} |
And now we are redirected back to the SignIn page, relying on the Onyx SESSION
update to set the loggedInDuringSession
again to true
, which will never happen because the Onyx SESSION
does not change: it already was in the default state when signing in as a suspended user, so calling clearStorageAndRedirect
did not make any change to the SESSION
key, therefore the Onyx.connect
in SessionUtils
was not triggered and the didUserLogInDuringSession
remains undefined
after reset, which makes the SessionUtils.didUserLogInDuringSession()
an unreliable source of truth. This all can be verified by adding corresponding logs inside the Onyx.connect
in SessionUtils
to track setting and resetting the value of loggedInDuringSession
.
What changes do you think we should make in order to solve the problem?
First, we should change the logic of the reset function to set the value to true
instead of undefined
. This is a safe change since resetDidUserLogInDuringSession is called only on redirectToSignIn
, therefore we expect that when a user lands on the SignIn
page, the sign-in process will be initiated, and we'll make use of loggedInDuringSession = true
after the successful sign in.
function resetDidUserLogInDuringSession() {
loggedInDuringSession = true;
}
Lines 47 to 49 in 5d45f0f
function resetDidUserLogInDuringSession() { | |
loggedInDuringSession = undefined; | |
} |
Second, remove the change introduced in #30730 , since now this logic will be handled by the fixed SessionUtils.didUserLogInDuringSession()
:
const shouldGetAllData = !!isUsingMemoryOnlyKeys || SessionUtils.didUserLogInDuringSession();
const shouldGetAllData = !!isUsingMemoryOnlyKeys || SessionUtils.didUserLogInDuringSession() || isLoggingInAsNewUser; |
This does both:
Fixes current issue:
Screen.Recording.2023-12-07.at.11.57.21-compressed.mp4
Keeps https://github.com//issues/29013 fixed:
Screen.Recording.2023-12-07.at.12.06.13-compressed.mp4
What alternative solutions did you explore? (Optional)
@paultsimura Thanks for the deeper investigation, Your proposal makes sense to me, this is a regression from #30730. Your solution looks good to me as well. @zukilover Thanks for the proposal, but it seems your solution is just a patch to the original issue. let's proceed with @paultsimura's proposal. 🎀 👀 🎀 C+ reviewed |
Triggered auto assignment to @chiragsalian, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
I think the proposal sounds good to me too. |
📣 @fedirjh 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app! |
📣 @paultsimura 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
Thank you. The PR is ready for review: #32775 |
PR was deployed to production on Dec 14, the automation didn't work 🤔 |
Thanks for the ping, Pavlo! I'll update the issue title manually |
BugZero Checklist:
Regression Test Proposal
|
@paultsimura $500 - paid ✔️ |
Context https://expensify.slack.com/archives/C03SDMF9YJ2/p1701887907195709 (private)
OpenApp should only be called when we are first initializing the app (after login basically) and ReconnectApp in any other case, but right now, we always call OpenApp on every reload, which is wrong.
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: