Skip to content

Fast-path login#2709

Open
corrideat wants to merge 19 commits intomasterfrom
2700-improve-logging-in-process
Open

Fast-path login#2709
corrideat wants to merge 19 commits intomasterfrom
2700-improve-logging-in-process

Conversation

@corrideat
Copy link
Copy Markdown
Member

Closes #2700

@corrideat corrideat requested a review from taoeffect March 9, 2025 17:42
@corrideat corrideat self-assigned this Mar 9, 2025
@cypress
Copy link
Copy Markdown

cypress bot commented Mar 9, 2025

group-income    Run #4701

Run Properties:  status check passed Passed #4701  •  git commit 00e1619467 ℹ️: Merge d2919292622276944f209f255b623fdae51c93de into 2ca21a2e4acfc31dddc678b9edb4...
Project group-income
Branch Review 2700-improve-logging-in-process
Run status status check passed Passed #4701
Run duration 13m 11s
Commit git commit 00e1619467 ℹ️: Merge d2919292622276944f209f255b623fdae51c93de into 2ca21a2e4acfc31dddc678b9edb4...
Committer Ricardo Iván Vieitez Parra
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 10
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 116
View all changes introduced in this branch ↗︎

@corrideat corrideat force-pushed the 2700-improve-logging-in-process branch 2 times, most recently from e79edbe to 7aef971 Compare March 13, 2025 00:20
Copy link
Copy Markdown
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

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

I'm not sure about this PR...

Comment on lines +398 to +399
await sbp('gi.db/settings/save', SETTING_CURRENT_USER, identityContractID)
sbp('okTurtles.events/emit', LOGIN, { identityContractID, encryptionParams, state })
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this being moved here?

The point of LOGIN, as far as I recall, was to indicate that we've logged in (at least partially).

This event is being emitted before that's happened, as the identity contract has not been loaded. It should at least be emitted after the identity contract has been loaded.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

But we have partially logged in at this point, in the sense of verifying credentials. This change is necessary:

  1. To allow for resumable login (as the issue says). Waiting for the entire identity contract means that logging in is an 'all or nothing' approach
  2. For offline use. If you see Offline cache #2508, you'll notice a similar change there. This is because in the case of an offline session, we obviously can't wait for sync to complete.

The LOGIN event also isn't to indicate that we've logged in, that's LOGIN_COMPLETE. See the LOGIN_FLOW.md file:

  • LOGIN: The LOGIN event represents an active login intent, which is to
    say, it represents that there is an active login process, which may either
    fail or succeed. This event can originate in the service worker (when
    establishing a new session) or in a local browsing context (when there is
    an active sesion).
  • LOGIN_COMPLETE: The LOGIN_COMPLETE is emitted following a LOGIN event
    and signifies that the login process completed successfully. This event is
    only local, which means that it doesn't originate on the service worker. Its
    purpose is to let the app know that an active user session exists and has been
    initialised.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the change I was talking about, which is uglier than this because it's testing for a condition that's difficult to detect (come to think of it, that might be why that PR is working during dev testing but not under real conditions).

https://github.com/okTurtles/group-income/pull/2508/files#diff-f9e60360184dfab0063900ef547eb2c2ec1f436744964bd7f532e6c437187c0aL422-R427

Copy link
Copy Markdown
Member

@taoeffect taoeffect Mar 13, 2025

Choose a reason for hiding this comment

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

The Join.vue page listens for LOGIN as well. If there's an issue syncing the identity contract, it might think everything worked out well. When you return to this PR, can you please double-check that as well?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, worth testing this to see what happens if syncing throws, and how recoverable the situation is.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What about renaming LOGIN to LOGIN_START, LOGIN_INIT, or LOGIN_BEGIN to mitigate the confusion?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

What about renaming LOGIN to LOGIN_START, LOGIN_INIT, or LOGIN_BEGIN to mitigate the confusion?

That sounds pretty reasonable

@corrideat corrideat force-pushed the 2700-improve-logging-in-process branch from 7aef971 to 71ccebb Compare March 21, 2025 19:58
@corrideat corrideat mentioned this pull request May 20, 2025
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.

Improve logging in process

3 participants