0
@@ -4,9 +4,16 @@ require File.dirname(__FILE__) + '/publishare/parser'
0
- # Modify these constants in your environment.rb to tailor the plugin to your authentication system
0
- if not Object.constants.include? "DEFAULT_REDIRECTION_HASH"
0
- DEFAULT_REDIRECTION_HASH = { :controller => 'account', :action => 'login' }
0
+ # Modify these constants in your environment.rb to tailor the plugin to
0
+ # your authentication system
0
+ if not Object.constants.include? "LOGIN_REQUIRED_REDIRECTION"
0
+ LOGIN_REQUIRED_REDIRECTION = {
0
+ :controller => 'session',
0
+ if not Object.constants.include? "PERMISSION_DENIED_REDIRECTION"
0
+ PERMISSION_DENIED_REDIRECTION = ''
0
if not Object.constants.include? "STORE_LOCATION_METHOD"
0
STORE_LOCATION_METHOD = :store_location
0
@@ -83,18 +90,17 @@ module Authorization
0
# Handle redirection within permit if authorization is denied.
0
return if not self.respond_to?( :redirect_to )
0
- redirection = DEFAULT_REDIRECTION_HASH
0
- redirection[:controller] = @options[:redirect_controller] if @options[:redirect_controller]
0
- redirection[:action] = @options[:redirect_action] if @options[:redirect_action]
0
- # Store url in session for return if this is available from authentication
0
+ # Store url in session for return if this is available from
0
send( STORE_LOCATION_METHOD ) if respond_to? STORE_LOCATION_METHOD
0
- flash[:notice] = "Permission denied. Your account cannot access the requested page."
0
+ if @current_user && !@current_user.nil? && @current_user != :false
0
+ flash[:notice] = @options[:permission_denied_message] || "Permission denied. You cannot access the requested page."
0
+ redirect_to @options[:permission_denied_redirection] || PERMISSION_DENIED_REDIRECTION
0
- flash[:notice] = @options[:redirect_message] ? @options[:redirect_message] : "Login is required"
0
+ flash[:notice] = @options[:login_required_message] || "Login is required to access the requested page."
0
+ redirect_to @options[:login_required_redirection] || LOGIN_REQUIRED_REDIRECTION
0
- redirect_to redirection
0
false # Want to short-circuit the filters
Comments
No one has commented yet.