From 35b77f6440b7b02331d38cfa093d527ff0ed28b7 Mon Sep 17 00:00:00 2001 From: Alexey Verkhovsky Date: Wed, 2 Nov 2005 09:04:53 +0000 Subject: [PATCH] A bit of spit and polish --- app/controllers/application.rb | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 9a601b72..b3789604 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -28,7 +28,7 @@ class ApplicationController < ActionController::Base end def check_authorization - if in_a_web? and needs_authorization?(@action_name) and not authorized? and + if in_a_web? and authorization_needed? and not authorized? and redirect_to :controller => 'wiki', :action => 'login', :web => @web_name return false end @@ -98,28 +98,26 @@ class ApplicationController < ActionController::Base def redirect_to_page(page_name = @page_name, web = @web_name) redirect_to :web => web, :controller => 'wiki', :action => 'show', - :id => (page_name || 'HomePage') + :id => (page_name or 'HomePage') end - @@REMEMBER_NOT = ['locked', 'save', 'back', 'file', 'pic', 'import'] def remember_location - if @response.headers['Status'] == '200 OK' - unless @@REMEMBER_NOT.include? action_name or @request.method != :get - @session[:return_to] = @request.request_uri - logger.debug("Session ##{session.object_id}: remembered URL '#{@session[:return_to]}'") - end + if @request.method == :get and + @response.headers['Status'] == '200 OK' and not + %w(locked save back file pic import).include?(action_name) + @session[:return_to] = @request.request_uri + logger.debug "Session ##{session.object_id}: remembered URL '#{@session[:return_to]}'" end end def rescue_action_in_public(exception) - message = <<-EOL + render :status => 500, :text => <<-EOL -

Internal Error 500

+

Internal Error

An application error occurred while processing your request.

- + EOL - render_text message, 'Internal Error 500' end def return_to_last_remembered @@ -170,8 +168,8 @@ class ApplicationController < ActionController::Base self.class.wiki end - def needs_authorization?(action) - not %w( login authenticate published rss_with_content rss_with_headlines ).include?(action) + def authorization_needed? + not %w( login authenticate published rss_with_content rss_with_headlines ).include?(action_name) end end