Sha256: 64e267eba05ab5831c7641710d7e72a89ac26785d296bc61262591f85e1ed830

Contents?: true

Size: 929 Bytes

Versions: 85

Compression:

Stored size: 929 Bytes

Contents

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

      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
            return
          end
        else
          if request.get?
            session["user_return_to"] = request.fullpath
            redirect_to new_user_session_path
            return
          end
        end

        raise exception
      end
    end
  end
end

Version data entries

85 entries across 85 versions & 2 rubygems

Version Path
social_stream-2.2.2 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-2.2.2 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-2.2.1 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-2.2.1 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-2.2.0 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-2.2.0 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-2.1.1 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-1.1.12 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-1.1.11 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-2.1.0 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-2.1.0 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-2.0.4 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-2.0.4 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-2.0.3 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-2.0.3 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-1.1.11 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-1.1.10 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-1.1.10 base/lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-base-1.1.9 lib/social_stream/controllers/cancan_devise_integration.rb
social_stream-1.1.9 base/lib/social_stream/controllers/cancan_devise_integration.rb