gitlab-org--gitlab-foss/lib/constraints/user_url_constrainer.rb
Dmitriy Zaporozhets 08d21fe899
Add small improvements to constrainers and specs
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-11-08 14:32:42 +02:00

15 lines
309 B
Ruby

require_relative 'constrainer_helper'
class UserUrlConstrainer
include ConstrainerHelper
def matches?(request)
id = extract_resource_path(request.path)
if id =~ Gitlab::Regex.namespace_regex
User.find_by('lower(username) = ?', id.downcase).present?
else
false
end
end
end