Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-11-07 16:16:04 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-11-07 16:16:04 +0300
commit82e551bdac7f2792e1d6aceb1b0b674dbd3dda81 (patch)
tree0fa71821cac92ccbf575b526682e0de0e4b623b4 /lib/constraints/user_url_constrainer.rb
parent76ff9fffcce353e33f407b78cf4256ef4dc50f6a (diff)
Refactor routing constraints
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib/constraints/user_url_constrainer.rb')
-rw-r--r--lib/constraints/user_url_constrainer.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/constraints/user_url_constrainer.rb b/lib/constraints/user_url_constrainer.rb
index 504a0f5d93e..9583cace022 100644
--- a/lib/constraints/user_url_constrainer.rb
+++ b/lib/constraints/user_url_constrainer.rb
@@ -1,7 +1,15 @@
-require 'constraints/namespace_url_constrainer'
+require_relative 'constrainer_helper'
-class UserUrlConstrainer < NamespaceUrlConstrainer
- def find_resource(id)
- User.find_by('lower(username) = ?', id.downcase)
+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)
+ else
+ false
+ end
end
end