From ba72f9dce873d23da44bc69f28a57f6d7fec9bfe Mon Sep 17 00:00:00 2001 From: Mitchell Henke Date: Fri, 8 Sep 2023 10:23:28 -0500 Subject: [PATCH] Memoize options method on TwoFactorLoginOptionsPresenter changelog: Internal, Performance, Memoize options method on TwoFactorLoginOptionsPresenter --- app/presenters/two_factor_login_options_presenter.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/presenters/two_factor_login_options_presenter.rb b/app/presenters/two_factor_login_options_presenter.rb index 355e06fc5ad..c9ddcdd710e 100644 --- a/app/presenters/two_factor_login_options_presenter.rb +++ b/app/presenters/two_factor_login_options_presenter.rb @@ -43,6 +43,7 @@ def restricted_options_warning_text end def options + return @options if defined?(@options) mfa = MfaContext.new(user) if @piv_cac_required @@ -63,7 +64,9 @@ def options # webauthn keys and phones. However, we only want to show one of each option # during login, except for phones, where we want to allow the user to choose # which MFA-enabled phone they want to use. - configurations.group_by(&:class).flat_map { |klass, set| klass.selection_presenters(set) } + @options = configurations.group_by(&:class).flat_map do |klass, set| + klass.selection_presenters(set) + end end def account_reset_or_cancel_link