Sha256: 02a1c954577ab1b24c5e8f1e3359c1faa713db96391946b55fa00d7616eb84e1

Contents?: true

Size: 895 Bytes

Versions: 6

Compression:

Stored size: 895 Bytes

Contents

require "refinery/core/authorisation_manager"
require "refinery/authentication/devise/authorisation_adapter"

module Refinery
  module Authentication
    module Devise
      class AuthorisationManager < Refinery::Core::AuthorisationManager

        # The user needs the 'refinery' role to access the admin.
        def authenticate!
          unless adapter.current_user.has_role?(:refinery)
            raise Zilch::Authorisation::NotAuthorisedException
          end

          adapter.current_user
        end

        # Override the default adapter specified in the superclass.
        def default_adapter
          @default_adapter ||= Refinery::Authentication::Devise::AuthorisationAdapter.new
        end

        # This allows a user to be supplied, bypassing the usual detection.
        def set_user!(user)
          adapter.current_user = user
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
refinerycms-authentication-devise-2.0.0 lib/refinery/authentication/devise/authorisation_manager.rb
refinerycms-authentication-devise-1.0.4 lib/refinery/authentication/devise/authorisation_manager.rb
refinerycms-authentication-devise-1.0.3 lib/refinery/authentication/devise/authorisation_manager.rb
refinerycms-authentication-devise-1.0.2 lib/refinery/authentication/devise/authorisation_manager.rb
refinerycms-authentication-devise-1.0.1 lib/refinery/authentication/devise/authorisation_manager.rb
refinerycms-authentication-devise-1.0.0 lib/refinery/authentication/devise/authorisation_manager.rb