Skip to content

Commit

Permalink
[Authenticator::Base] case_insensitive_find_by_userid cache
Browse files Browse the repository at this point in the history
  • Loading branch information
NickLaMuro committed Sep 2, 2020
1 parent b1bc828 commit 06c71cc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/authenticator/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,13 @@ def failure_reason(_username, _request)
end

def case_insensitive_find_by_userid(username, lookup_scope: nil)
@lookup ||= {}
@lookup[username] ||= {}
return @lookup[username][lookup_scope] if @lookup[username][lookup_scope]

base = User.send(User::LOOKUP_SCOPES[lookup_scope])
user = base.lookup_by_userid(username)
user || base.in_my_region.where('lower(userid) = ?', username.downcase).order(:lastlogon).last
@lookup[username][lookup_scope] = user || base.in_my_region.where('lower(userid) = ?', username.downcase).order(:lastlogon).last
end

def userid_for(_identity, username)
Expand Down

0 comments on commit 06c71cc

Please sign in to comment.