summaryrefslogtreecommitdiff
path: root/lib/api/internal.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-03-25 04:16:45 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-03-25 04:16:45 +0000
commit8f3f6e9efbbacf5e52f98324944f644630da2f18 (patch)
treeb8bd189a7dc4919a832eb583441d398b7294cb8c /lib/api/internal.rb
parentd7aecf68e02cb9ac3b7e022aca60e15a65a62ac6 (diff)
parent4745424bd3b7f6e13e86ebf985977ad3268881e3 (diff)
downloadgitlab-ce-8f3f6e9efbbacf5e52f98324944f644630da2f18.tar.gz
Merge branch 'api-internal-errors' into 'master'
Respond with full GitAccess error if user has project read access. Should help with debugging #1236. cc @marin See merge request !437
Diffstat (limited to 'lib/api/internal.rb')
-rw-r--r--lib/api/internal.rb38
1 files changed, 18 insertions, 20 deletions
diff --git a/lib/api/internal.rb b/lib/api/internal.rb
index 753d0fcbd98..f98a17773e7 100644
--- a/lib/api/internal.rb
+++ b/lib/api/internal.rb
@@ -17,42 +17,40 @@ module API
post "/allowed" do
status 200
- actor = if params[:key_id]
- Key.find_by(id: params[:key_id])
- elsif params[:user_id]
- User.find_by(id: params[:user_id])
- end
+ actor =
+ if params[:key_id]
+ Key.find_by(id: params[:key_id])
+ elsif params[:user_id]
+ User.find_by(id: params[:user_id])
+ end
unless actor
return Gitlab::GitAccessStatus.new(false, 'No such user or key')
end
project_path = params[:project]
-
+
# Check for *.wiki repositories.
# Strip out the .wiki from the pathname before finding the
# project. This applies the correct project permissions to
# the wiki repository as well.
- access =
- if project_path.end_with?('.wiki')
- project_path.chomp!('.wiki')
- Gitlab::GitAccessWiki.new
- else
- Gitlab::GitAccess.new
- end
+ wiki = project_path.end_with?('.wiki')
+ project_path.chomp!('.wiki') if wiki
project = Project.find_with_namespace(project_path)
if project
- status = access.check(
- actor,
- params[:action],
- project,
- params[:changes]
- )
+ access =
+ if wiki
+ Gitlab::GitAccessWiki.new(actor, project)
+ else
+ Gitlab::GitAccess.new(actor, project)
+ end
+
+ status = access.check(params[:action], params[:changes])
end
- if project && status && status.allowed?
+ if project && access.can_read_project?
status
else
Gitlab::GitAccessStatus.new(false, 'No such project')