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

feat: utils for two factor auth modal #316

Merged
merged 11 commits into from
Apr 4, 2023

Conversation

ttebify
Copy link
Collaborator

@ttebify ttebify commented Apr 2, 2023

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #311

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I documented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@ttebify ttebify requested a review from chetannn April 2, 2023 11:10
@ttebify
Copy link
Collaborator Author

ttebify commented Apr 2, 2023

Here is what I noticed while working on this feature.

The current implementation of the 2FA authentication flow in our application is causing an unnecessary step for our users. After a user verifies their 2FA at login, the application writes the state to the Redis store. However, when a user logs in, the application already checks the Redis store and returns that the user has been verified, which means the 2FA modal is never shown.

How can we fix this? I suggest that we stop relying on the user's verification state stored in Redis. Instead, we should require the user to verify themselves every time we need to perform critical actions that require verification.

The current implementation does not address these issues, I have created it as a draft first for us to go over and propose ways in which we can properly handle user verification.

@dahal
Copy link
Member

dahal commented Apr 3, 2023

The current implementation of the 2FA authentication flow in our application is causing an unnecessary step for our users. After a user verifies their 2FA at login, the application writes the state to the Redis store. However, when a user logs in, the application already checks the Redis store and returns that the user has been verified, which means the 2FA modal is never shown.

This is intentional, to avoid asking 2FA to users too many times when they are logging in from same device. We use fingerprint to identify if user is using same device or different. The util however, when triggered should open every time if the user has enabled 2fa (regardless of whether or they have verified.)

@ttebify
Copy link
Collaborator Author

ttebify commented Apr 3, 2023

The current implementation of the 2FA authentication flow in our application is causing an unnecessary step for our users. After a user verifies their 2FA at login, the application writes the state to the Redis store. However, when a user logs in, the application already checks the Redis store and returns that the user has been verified, which means the 2FA modal is never shown.

This is intentional, to avoid asking 2FA to users too many times when they are logging in from same device. We use fingerprint to identify if user is using same device or different. The util however, when triggered should open every time if the user has enabled 2fa (regardless of whether or they have verified.)

Ok that makes sense, does it mean that here:

// Check two-factor auth status
if (user.twoFactorEnabled && !twoFactorVerified) {
  setOpenModal(true);
} else if (twoFactorVerified) {
  // Two-factor auth already verified, execute the original function
  await fn();
} else {
  // Two-factor auth disabled, execute the original function
  await fn();
}

I can do without checking if twoFactorVerified is false?

@ttebify ttebify marked this pull request as ready for review April 4, 2023 01:36
@ttebify ttebify requested a review from dahal April 4, 2023 01:38
@Aju100
Copy link
Contributor

Aju100 commented Apr 4, 2023

Hey @ttebify , one test case is failed out there for PR title validation. Can you please update the PR title where suggestions are being given by github bot.

@ttebify
Copy link
Collaborator Author

ttebify commented Apr 4, 2023

Hey @ttebify , one test case is failed out there for PR title validation. Can you please update the PR title where suggestions are being given by github bot.

Sure, I'll do that thanks

@ttebify ttebify changed the title Feat/utils for two factor auth modal feat: utils for two factor auth modal Apr 4, 2023
Copy link
Member

@dahal dahal left a comment

Choose a reason for hiding this comment

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

Impressive work @ttebify 🏅 🎉

@dahal dahal merged commit 2fae218 into main Apr 4, 2023
7 of 8 checks passed
@dahal dahal deleted the feat/utils-for-two-factor-auth-modal branch April 4, 2023 07:42
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.

[FEATURE]: Create an utils for Two Factor Authentication modal
4 participants