summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/checks/change_access.rb4
-rw-r--r--lib/gitlab/git_access.rb14
-rw-r--r--lib/gitlab/git_access_status.rb11
-rw-r--r--lib/gitlab/git_access_wiki.rb6
4 files changed, 9 insertions, 26 deletions
diff --git a/lib/gitlab/checks/change_access.rb b/lib/gitlab/checks/change_access.rb
index e9782623be5..b6805230348 100644
--- a/lib/gitlab/checks/change_access.rb
+++ b/lib/gitlab/checks/change_access.rb
@@ -31,13 +31,13 @@ module Gitlab
end
def exec
- return GitAccessStatus.new(true) if skip_authorization
+ return true if skip_authorization
push_checks
branch_checks
tag_checks
- GitAccessStatus.new(true)
+ true
end
protected
diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb
index f44426d62b8..4807dc9a5fb 100644
--- a/lib/gitlab/git_access.rb
+++ b/lib/gitlab/git_access.rb
@@ -51,7 +51,7 @@ module Gitlab
check_push_access!(changes)
end
- build_status_object(true)
+ true
end
def guest_can_download_code?
@@ -167,11 +167,9 @@ module Gitlab
# Iterate over all changes to find if user allowed all of them to be applied
changes_list.each do |change|
- status = check_single_change_access(change)
- unless status.allowed?
- # If user does not have access to make at least one change - cancel all push
- raise UnauthorizedError, status.message
- end
+ # If user does not have access to make at least one change, cancel all
+ # push by allowing the exception to bubble up
+ check_single_change_access(change)
end
end
@@ -246,9 +244,5 @@ module Gitlab
nil
end
end
-
- def build_status_object(status)
- Gitlab::GitAccessStatus.new(status)
- end
end
end
diff --git a/lib/gitlab/git_access_status.rb b/lib/gitlab/git_access_status.rb
deleted file mode 100644
index 94edf80c0f6..00000000000
--- a/lib/gitlab/git_access_status.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-module Gitlab
- class GitAccessStatus
- attr_accessor :status, :message
- alias_method :allowed?, :status
-
- def initialize(status, message = '')
- @status = status
- @message = message
- end
- end
-end
diff --git a/lib/gitlab/git_access_wiki.rb b/lib/gitlab/git_access_wiki.rb
index 4c87482430f..1fe5155c093 100644
--- a/lib/gitlab/git_access_wiki.rb
+++ b/lib/gitlab/git_access_wiki.rb
@@ -13,11 +13,11 @@ module Gitlab
end
def check_single_change_access(change)
- if user_access.can_do_action?(:create_wiki)
- build_status_object(true)
- else
+ unless user_access.can_do_action?(:create_wiki)
raise UnauthorizedError, ERROR_MESSAGES[:write_to_wiki]
end
+
+ true
end
end
end