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 Jan 22, 2021
1 parent d5d8e6e commit 8f55dae
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 @@ -245,9 +245,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 || User.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 8f55dae

Please sign in to comment.