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
2 files
+ 16
6
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 4
6
@@ -153,7 +153,6 @@ def reorder_users(users)
requires :username, type: String, desc: 'The username of the user'
use :optional_attributes
end
# rubocop: disable CodeReuse/ActiveRecord
post do
authenticated_as_admin!
@@ -164,17 +163,16 @@ def reorder_users(users)
present user, with: Entities::UserPublic, current_user: current_user
else
conflict!('Email has already been taken') if User
.where(email: user.email)
.iwhere(email: user.email)
.count > 0
conflict!('Username has already been taken') if User
.where(username: user.username)
.iwhere(username: user.username)
.count > 0
render_validation_error!(user)
end
end
# rubocop: enable CodeReuse/ActiveRecord
desc 'Update a user. Available only for admins.' do
success Entities::UserPublic
@@ -196,11 +194,11 @@ def reorder_users(users)
not_found!('User') unless user
conflict!('Email has already been taken') if params[:email] &&
User.where(email: params[:email])
User.iwhere(email: params[:email])
.where.not(id: user.id).count > 0
conflict!('Username has already been taken') if params[:username] &&
User.where(username: params[:username])
User.iwhere(username: params[:username])
.where.not(id: user.id).count > 0
user_params = declared_params(include_missing: false)
Loading