Skip to content
Snippets Groups Projects

Make getting a user by the username case insensitive

Merged William George requested to merge awgeorge1/gitlab-ce:master into master
All threads resolved!
Compare and Show latest version
5 files
+ 79
71
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -34,8 +34,8 @@ def find_by_username!
end
# Tries to find a User by username or id, returning nil if none could be found.
def execute
if input_is_id?(@username_or_id)
def find_by_id_or_username
if input_is_id?
find_by_id
else
find_by_username
@@ -44,15 +44,15 @@ def execute
# Tries to find a User by username or id, raising a `ActiveRecord::RecordNotFound` if it could
# not be found.
def execute!
if input_is_id?(@username_or_id)
def find_by_id_or_username!
if input_is_id?
find_by_id!
else
find_by_username!
end
end
def input_is_id?(input)
input.is_a?(Numeric) || input =~ /^\d+$/
def input_is_id?
@username_or_id.is_a?(Numeric) || @username_or_id =~ /^\d+$/
end
end
Loading