summaryrefslogtreecommitdiff
path: root/lib/constraints/user_url_constrainer.rb
blob: 4d722ad5af248af5c4b62504d7fbd628a81ad052 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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