LG-6274: Allow users to select phone as their sole second option#6356
Merged
LG-6274: Allow users to select phone as their sole second option#6356
Conversation
66bbe95 to
0222a76
Compare
67a9e08 to
3d17fc4
Compare
aduth
reviewed
May 18, 2022
app/forms/two_factor_options_form.rb
Outdated
Comment on lines
56
to
60
Contributor
There was a problem hiding this comment.
For mixed operators like || and &&, can we add parentheses around the parts which are meant to be tested together? I don't know the order of operations off the top of my head, so this is hard for me to interpret.
Also, we could return the boolean result directly, rather than extra return statement.
Suggested change
| if count >= 2 || count == 1 && MfaContext.new(user).phone_configurations.none? | |
| return true | |
| else | |
| return false | |
| end | |
| count >= 2 || (count == 1 && MfaContext.new(user).phone_configurations.none?) |
app/forms/two_factor_options_form.rb
Outdated
Comment on lines
64
to
62
Contributor
There was a problem hiding this comment.
Is the parentheses meaningful here?
Suggested change
| (IdentityConfig.store.select_multiple_mfa_options && | |
| phone_selected? && phone_only_mfa_method?) && | |
| !phone_alternative_enabled? | |
| IdentityConfig.store.select_multiple_mfa_options && | |
| phone_selected? && | |
| phone_only_mfa_method? && | |
| !phone_alternative_enabled? |
Contributor
Author
There was a problem hiding this comment.
The parenthesis stayed around as I was refactoring
39fbe51 to
023ceb8
Compare
75ee7ee to
352edad
Compare
changelog: Upcoming feature, multi factor authentication, fix bug to add phone as second MFA option
352edad to
65c1de0
Compare
aduth
approved these changes
May 20, 2022
Comment on lines
72
to
91
| %w[phone].each do |selection| | ||
| result = subject.submit(selection: selection) | ||
|
|
||
| expect(result.success?).to eq false | ||
| end | ||
| end | ||
| end | ||
|
|
||
| context 'when a user wants to select phone as their second authentication method' do | ||
| let(:user) { create(:user, :with_authentication_app) } | ||
| before do | ||
| allow(IdentityConfig.store).to receive(:select_multiple_mfa_options).and_return(true) | ||
| end | ||
|
|
||
| it 'submits the form' do | ||
| %w[phone].each do |selection| | ||
| result = subject.submit(selection: ['phone']) | ||
|
|
||
| expect(result.success?).to eq true | ||
| end |
Contributor
There was a problem hiding this comment.
The loops here don't seem to be necessary for a single item, and in the second case we're already not using the loop parameter.
Suggested change
| %w[phone].each do |selection| | |
| result = subject.submit(selection: selection) | |
| expect(result.success?).to eq false | |
| end | |
| end | |
| end | |
| context 'when a user wants to select phone as their second authentication method' do | |
| let(:user) { create(:user, :with_authentication_app) } | |
| before do | |
| allow(IdentityConfig.store).to receive(:select_multiple_mfa_options).and_return(true) | |
| end | |
| it 'submits the form' do | |
| %w[phone].each do |selection| | |
| result = subject.submit(selection: ['phone']) | |
| expect(result.success?).to eq true | |
| end | |
| result = subject.submit(selection: ['phone']) | |
| expect(result.success?).to eq false | |
| end | |
| end | |
| context 'when a user wants to select phone as their second authentication method' do | |
| let(:user) { create(:user, :with_authentication_app) } | |
| before do | |
| allow(IdentityConfig.store).to receive(:select_multiple_mfa_options).and_return(true) | |
| end | |
| it 'submits the form' do | |
| result = subject.submit(selection: ['phone']) | |
| expect(result.success?).to eq true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This ticket fixes a bug that emerged after #6278 and #6276 were completed
Current state: In setting up an account, the user would select one 2FA method (except for phone due to Kantara requirements). Once setup is complete, if the user selects the option to add a second MFA method, they will not be proceed with phone setup due to the validation added for
Future state: If the user selects phone as their sole additional authentication method, the user will be able to select the phone option and proceed with setup.
After
