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
vkhater-social_stream-0.16.3.3 base/lib/social_stream/controllers/cancan_devise_integration.rb
vkhater-social_stream-base-0.11.2 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-0.18.2 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-0.13.2 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-0.18.1 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-0.13.1 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-0.18.0 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-0.13.0 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-0.17.1 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-0.12.1 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-0.17.0 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-0.12.0 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-0.16.3 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-0.11.2 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-0.16.2 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-0.11.1 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-0.16.1 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-0.11.0 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-0.15.8 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-0.10.11 lib/social_stream/controllers/cancan_devise_integration.rb