-
Notifications
You must be signed in to change notification settings - Fork 112
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
LG-12636: Show recommended PIV option for .gov/.mil email #10252
Changes from all commits
e07258e
45ad1c1
c7df9e4
a7aaf3c
8213d09
2895c4b
037fd69
16a3721
0000eb3
04e56fb
a7bc8d7
7a1239d
02bb360
fe437b0
3982792
52b78f5
97d365b
8819535
b69ecfd
375e353
a8a4a7f
06661bb
3e2531c
ec43d0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class TagComponent < BaseComponent | ||
attr_reader :big, :informative, :tag_options | ||
alias_method :big?, :big | ||
alias_method :informative?, :informative | ||
|
||
def initialize(big: false, informative: false, **tag_options) | ||
@big = big | ||
@informative = informative | ||
@tag_options = tag_options | ||
end | ||
|
||
def css_class | ||
classes = ['usa-tag', *tag_options[:class]] | ||
classes << 'usa-tag--big' if big? | ||
classes << 'usa-tag--informative' if informative? | ||
classes | ||
end | ||
|
||
def call | ||
content_tag(:span, content, **tag_options, class: css_class) | ||
end | ||
|
||
private :big, :informative | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
class TwoFactorOptionsPresenter | ||
include ActionView::Helpers::TranslationHelper | ||
|
||
attr_reader :user, :after_mfa_setup_path, :return_to_sp_cancel_path | ||
attr_reader :user, | ||
:after_mfa_setup_path, | ||
:return_to_sp_cancel_path, | ||
:phishing_resistant_required, | ||
:piv_cac_required, | ||
:user_agent | ||
|
||
delegate :two_factor_enabled?, to: :mfa_policy | ||
|
||
|
@@ -24,21 +29,22 @@ def initialize( | |
end | ||
|
||
def options | ||
webauthn_platform_option + totp_option + phone_options + | ||
backup_code_option + webauthn_option + piv_cac_option | ||
all_options_sorted.select(&:visible?) | ||
end | ||
|
||
# Array of possible options selected by the user to display on the | ||
# add additional MFA page | ||
def all_user_selected_options | ||
def all_options_sorted | ||
[ | ||
TwoFactorAuthentication::SetUpWebauthnPlatformSelectionPresenter.new(user: user), | ||
TwoFactorAuthentication::SetUpAuthAppSelectionPresenter.new(user: user), | ||
TwoFactorAuthentication::SetUpPhoneSelectionPresenter.new(user: user), | ||
TwoFactorAuthentication::SetUpBackupCodeSelectionPresenter.new(user: user), | ||
TwoFactorAuthentication::SetUpWebauthnSelectionPresenter.new(user: user), | ||
TwoFactorAuthentication::SetUpPivCacSelectionPresenter.new(user: user), | ||
] | ||
TwoFactorAuthentication::SetUpWebauthnPlatformSelectionPresenter, | ||
TwoFactorAuthentication::SetUpAuthAppSelectionPresenter, | ||
TwoFactorAuthentication::SetUpPhoneSelectionPresenter, | ||
TwoFactorAuthentication::SetUpBackupCodeSelectionPresenter, | ||
TwoFactorAuthentication::SetUpWebauthnSelectionPresenter, | ||
TwoFactorAuthentication::SetUpPivCacSelectionPresenter, | ||
].map do |klass| | ||
klass.new(user:, piv_cac_required:, phishing_resistant_required:, user_agent:) | ||
end. | ||
partition(&:recommended?). | ||
flatten | ||
end | ||
|
||
def icon | ||
|
@@ -97,43 +103,6 @@ def skip_label | |
|
||
private | ||
|
||
def piv_cac_option | ||
return [] unless current_device_is_desktop? | ||
[TwoFactorAuthentication::SetUpPivCacSelectionPresenter.new(user: user)] | ||
end | ||
|
||
def webauthn_option | ||
return [] if piv_cac_required? | ||
[TwoFactorAuthentication::SetUpWebauthnSelectionPresenter.new(user: user)] | ||
end | ||
|
||
def webauthn_platform_option | ||
return [] if piv_cac_required? | ||
[TwoFactorAuthentication::SetUpWebauthnPlatformSelectionPresenter.new(user: user)] | ||
end | ||
|
||
def phone_options | ||
if piv_cac_required? || phishing_resistant_only? || IdentityConfig.store.hide_phone_mfa_signup | ||
return [] | ||
else | ||
[TwoFactorAuthentication::SetUpPhoneSelectionPresenter.new(user: user)] | ||
end | ||
end | ||
|
||
def totp_option | ||
return [] if piv_cac_required? || phishing_resistant_only? | ||
[TwoFactorAuthentication::SetUpAuthAppSelectionPresenter.new(user: user)] | ||
end | ||
|
||
def backup_code_option | ||
return [] if piv_cac_required? || phishing_resistant_only? | ||
[TwoFactorAuthentication::SetUpBackupCodeSelectionPresenter.new(user: user)] | ||
end | ||
|
||
def current_device_is_desktop? | ||
!BrowserCache.parse(@user_agent).mobile? | ||
end | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like how you refactored all of that. |
||
def piv_cac_required? | ||
@piv_cac_required | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,13 @@ | |
<% end %> | ||
<span id="two_factor_options_form_selection_info_<%= option.type %>" aria-hidden="true" class="usa-checkbox__label-description"> | ||
<%= option.info %> | ||
<% if option.recommended? %> | ||
<br /> | ||
<%= render TagComponent.new( | ||
informative: true, | ||
class: 'margin-top-1', | ||
).with_content(t('two_factor_authentication.recommended')) %> | ||
<% end %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The 'Added' tag is similar to this but has the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ARIA is a little hard to follow here, but I think this is correct as-is.
Example how this announces in Safari + VoiceOver: |
||
</span> | ||
</div> | ||
<% end %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this line be considered as a bit of mental gymnastics? I was thinking
!browser.mobile?
could go into something likeis_browser_mobile?
for readability.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, to the readability point, I initially tried
browser.desktop?
to avoid the negation, before realizing that the method doesn't actually exist and fixing in 7a1239d.Personally I think the negation isn't too bad to warrant adding another method here.