Clean up a few before_filters
This commit is contained in:
parent
4be1a58a24
commit
cd674bbb36
2 changed files with 15 additions and 20 deletions
|
@ -42,10 +42,8 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def check_authorization
|
||||
if in_a_web? and authorization_needed? and not authorized?
|
||||
redirect_to :controller => 'wiki', :action => 'login', :web => @web_name
|
||||
return false
|
||||
end
|
||||
redirect_to(:controller => 'wiki', :action => 'login',
|
||||
:web => @web_name) if in_a_web? and authorization_needed? and not authorized?
|
||||
end
|
||||
|
||||
def connect_to_model
|
||||
|
@ -55,10 +53,8 @@ class ApplicationController < ActionController::Base
|
|||
@author = cookies['author'] || 'AnonymousCoward'
|
||||
if @web_name
|
||||
@web = @wiki.webs[@web_name]
|
||||
if @web.nil?
|
||||
render(:status => 404, :text => "Unknown web '#{@web_name}'", :layout => 'error')
|
||||
return false
|
||||
end
|
||||
render(:status => 404, :text => "Unknown web '#{@web_name}'",
|
||||
:layout => 'error') if @web.nil?
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -252,7 +248,6 @@ class ApplicationController < ActionController::Base
|
|||
layout = false if %w(tex tex_list).include?(action_name)
|
||||
headers['Allow'] = 'POST'
|
||||
render(:status => 405, :text => 'You must use an HTTP POST', :layout => layout)
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
|
|
@ -88,17 +88,14 @@ class FileController < ApplicationController
|
|||
protected
|
||||
|
||||
def check_authorized
|
||||
if authorized? or @web.published?
|
||||
return true
|
||||
else
|
||||
unless authorized? or @web.published?
|
||||
@hide_navigation = true
|
||||
render(:status => 403, :text => 'This web is private', :layout => true)
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def check_allow_uploads
|
||||
render(:status => 404, :text => "Web #{params['web'].inspect} not found", :layout => 'error') and return false unless @web
|
||||
if @web
|
||||
if @web.allow_uploads? and authorized?
|
||||
return true
|
||||
else
|
||||
|
@ -106,6 +103,9 @@ class FileController < ApplicationController
|
|||
render(:status => 403, :text => 'File uploads are blocked by the webmaster', :layout => true)
|
||||
return false
|
||||
end
|
||||
else
|
||||
render(:status => 404, :text => "Web #{params['web'].inspect} not found", :layout => 'error')
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Reference in a new issue