Sha256: ab5a7ecab127a49f7b23aa0f6772797716707b4fd313a9af36dbea920ac19d36

Contents?: true

Size: 895 Bytes

Versions: 49

Compression:

Stored size: 895 Bytes

Contents

module SocialStream
  module Controllers
    # Common methods added to ApplicationController
    module CancanDeviseIntegration
      extend ActiveSupport::Concern
      
      module InstanceMethods

        private

        # Catch some authorization errors:
        #
        # * Redirect to home when the user changes the session and the resource
        #   is not accesible with the new representation
        #
        # * Redirect to login if the user is trying to access a protected resource
        #   and she is not authenticated
        def rescue_from_access_denied(exception)
          if user_signed_in?
            if params[:s].present? && controller_name != 'home'
              redirect_to :home
            else
              raise exception
            end
          else
            redirect_to new_user_session_path
          end
        end
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 4 rubygems

Version Path
social_stream-base-0.10.1 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-0.13.0 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-0.10.0 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-0.12.14 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-0.9.36 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-0.12.13 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-0.9.35 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-0.12.12 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-0.9.34 lib/social_stream/controllers/cancan_devise_integration.rb