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
4 files
+ 12
12
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -35,7 +35,7 @@ def find_by_username!
# 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)
if input_is_id?
find_by_id
else
find_by_username
@@ -45,14 +45,14 @@ 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)
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