Commit dad83166 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #5350 from NARKOZ/patch-0

fix variable name
parents 9afc930b 12420a22
......@@ -199,11 +199,7 @@ class User < ActiveRecord::Base
end
def by_username_or_id(name_or_id)
if (name_or_id.is_a?(Integer))
User.find_by_id(name_or_id)
else
User.find_by_username(name_or_id)
end
where('username = ? OR id = ?', name_or_id, name_or_id).first
end
def build_user(attrs = {}, options= {})
......
......@@ -11,12 +11,8 @@ module API
# If the sudo is the current user do nothing
if (identifier && !(@current_user.id == identifier || @current_user.username == identifier))
render_api_error!('403 Forbidden: Must be admin to use sudo', 403) unless @current_user.is_admin?
begin
@current_user = User.by_username_or_id(identifier)
rescue => ex
not_found!("No user id or username for: #{identifier}")
end
not_found!("No user id or username for: #{identifier}") if current_user.nil?
@current_user = User.by_username_or_id(identifier)
not_found!("No user id or username for: #{identifier}") if @current_user.nil?
end
@current_user
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment