Blocking of file uploads by admin
This commit is contained in:
parent
6c020342a3
commit
b747b611b3
|
@ -6,6 +6,8 @@ class FileController < ApplicationController
|
||||||
|
|
||||||
layout 'default'
|
layout 'default'
|
||||||
|
|
||||||
|
before_filter :check_allow_uploads
|
||||||
|
|
||||||
def file
|
def file
|
||||||
check_path
|
check_path
|
||||||
|
|
||||||
|
@ -43,6 +45,17 @@ class FileController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def check_allow_uploads
|
||||||
|
unless @web.allow_uploads
|
||||||
|
render_text 'File uploads are blocked by the webmaster', '403 Forbidden'
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def check_path
|
def check_path
|
||||||
|
|
|
@ -114,4 +114,14 @@ class FileControllerTest < Test::Unit::TestCase
|
||||||
@home.display_content
|
@home.display_content
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_uploads_blocking
|
||||||
|
@web.allow_uploads = true
|
||||||
|
r = process 'file', 'web' => 'wiki1', 'id' => 'filename'
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
@web.allow_uploads = false
|
||||||
|
r = process 'file', 'web' => 'wiki1', 'id' => 'filename'
|
||||||
|
assert_equal '403 Forbidden', r.headers['Status']
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue