summaryrefslogtreecommitdiff
path: root/lib/api/helpers.rb
diff options
context:
space:
mode:
authorJeremy Anderson <jeremy@code-adept.com>2012-07-27 22:18:04 -0400
committerJeremy Anderson <jeremy@code-adept.com>2012-07-27 22:18:04 -0400
commite6edaa3b502090f461b58c439ea476da2d37f039 (patch)
treea9cd55849df039f524ff2b5cbce55c38e9768e04 /lib/api/helpers.rb
parent0301ba3315436a2dc466415ab0a3dd4fd7be3931 (diff)
parent3caf0aa89a964b8b3dcd21536e5bc274165ed2a2 (diff)
downloadgitlab-ce-e6edaa3b502090f461b58c439ea476da2d37f039.tar.gz
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r--lib/api/helpers.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 424a17b283c..c1ea05667ae 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -4,6 +4,16 @@ module Gitlab
@current_user ||= User.find_by_authentication_token(params[:private_token])
end
+ def user_project
+ if @project ||= current_user.projects.find_by_id(params[:id]) ||
+ current_user.projects.find_by_code(params[:id])
+ else
+ error!({'message' => '404 Not found'}, 404)
+ end
+
+ @project
+ end
+
def authenticate!
error!({'message' => '401 Unauthorized'}, 401) unless current_user
end