summaryrefslogtreecommitdiff
path: root/app/controllers/snippets_controller.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-12-02 11:20:51 +0100
committerDouwe Maan <douwe@gitlab.com>2015-12-02 11:20:51 +0100
commit2955ca613bfe13cd15c43d082be934075636ae0e (patch)
tree4c367f600ff0b7f273c3b4194e97060141b54b02 /app/controllers/snippets_controller.rb
parente1e67d383e4b56c9e1848aebc175402a71502e82 (diff)
parent09e712c0fb721059e4b2619eb9fc104257fc492d (diff)
downloadgitlab-ce-2955ca613bfe13cd15c43d082be934075636ae0e.tar.gz
Merge branch 'master' into reference-pipeline-and-caching
Diffstat (limited to 'app/controllers/snippets_controller.rb')
-rw-r--r--app/controllers/snippets_controller.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb
index 9f9f9a92f11..c72df73af46 100644
--- a/app/controllers/snippets_controller.rb
+++ b/app/controllers/snippets_controller.rb
@@ -1,6 +1,9 @@
class SnippetsController < ApplicationController
before_action :snippet, only: [:show, :edit, :destroy, :update, :raw]
+ # Allow read snippet
+ before_action :authorize_read_snippet!, only: [:show, :raw]
+
# Allow modify snippet
before_action :authorize_update_snippet!, only: [:edit, :update]
@@ -79,10 +82,14 @@ class SnippetsController < ApplicationController
[Snippet::PUBLIC, Snippet::INTERNAL]).
find(params[:id])
else
- PersonalSnippet.are_public.find(params[:id])
+ PersonalSnippet.find(params[:id])
end
end
+ def authorize_read_snippet!
+ authenticate_user! unless can?(current_user, :read_personal_snippet, @snippet)
+ end
+
def authorize_update_snippet!
return render_404 unless can?(current_user, :update_personal_snippet, @snippet)
end