Skip to content
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

fix: clean up two factor #26901

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

fix: clean up two factor #26901

wants to merge 1 commit into from

Conversation

zlwaterfield
Copy link
Contributor

@zlwaterfield zlwaterfield commented Dec 13, 2024

Changes

There's currently a race condition introduced here https://github.com/PostHog/posthog/pull/26813/files that may double trigger the set up call and make it so the QR code being rendered doesn't match the token stored in the session.

This PR also cleans up the set up code so the modal is only rendered once and not in 3 locations.

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

It doesn't have an impact.

How did you test this code?

Manually.

I'd love for the review to pull this locally and test all 3 cases to make sure it's all working

  1. Set up 2FA from profile
  2. Set up 2FA from members list (click on 2FA not enabled tag)
  3. Turn on the 2FA enforcement on the organization, reload and set it up via the forced modal.

Copy link
Contributor

Size Change: 0 B

Total Size: 1.11 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 1.11 MB

compressed-size-action

@surbhi-posthog
Copy link
Contributor

I see failing tests, so I'm just going to re-run them to see if they pass

Copy link
Member

@raquelmsmith raquelmsmith left a comment

Choose a reason for hiding this comment

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

I was wondering if a race condition would happen here..

Approving because my one comment is non-blocking but it might be better to change it up a bit.

actions.loadStatus()

if (values.user && values.user.organization?.enforce_2fa && !values.user.is_2fa_enabled) {
actions.openTwoFactorSetupModal(true)
Copy link
Member

Choose a reason for hiding this comment

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

I feel like this is confusing because the modal could be already open (if it's forced open), yet we're saying here to open the modal. but instead of it opening the modal, what's actually happening is this side-effect where startSetup is called.

I think it technically works but it's confusing and took me a bit to understand the code.

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.

3 participants