diff options
author | GitLab Release Tools Bot <delivery-team+release-tools@gitlab.com> | 2020-09-02 12:39:03 +0000 |
---|---|---|
committer | GitLab Release Tools Bot <delivery-team+release-tools@gitlab.com> | 2020-09-02 12:39:03 +0000 |
commit | 90432d32acd69cf91e647fc508045659cae26b1a (patch) | |
tree | 2b2da74ca70007a0343a131ed187dcdbdbfeb7dd /app/controllers/sessions_controller.rb | |
parent | f4a969f7f495978a7e656c69c929c9fdac111cff (diff) | |
parent | 417a126de5e49fb7c63bb3f23b22bc4a484ac359 (diff) | |
download | gitlab-ce-90432d32acd69cf91e647fc508045659cae26b1a.tar.gz |
Merge remote-tracking branch 'dev/13-3-stable' into 13-3-stable
Diffstat (limited to 'app/controllers/sessions_controller.rb')
-rw-r--r-- | app/controllers/sessions_controller.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index f82212591b6..9435b9887e9 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -8,6 +8,7 @@ class SessionsController < Devise::SessionsController include Recaptcha::Verify include RendersLdapServers include KnownSignIn + include Gitlab::Utils::StrongMemoize skip_before_action :check_two_factor_requirement, only: [:destroy] # replaced with :require_no_authentication_without_flash @@ -197,10 +198,14 @@ class SessionsController < Devise::SessionsController end def find_user - if session[:otp_user_id] - User.find(session[:otp_user_id]) - elsif user_params[:login] - User.by_login(user_params[:login]) + strong_memoize(:find_user) do + if session[:otp_user_id] && user_params[:login] + User.by_id_and_login(session[:otp_user_id], user_params[:login]).first + elsif session[:otp_user_id] + User.find(session[:otp_user_id]) + elsif user_params[:login] + User.by_login(user_params[:login]) + end end end |