Sha256: 441b3c2f233884f9d8a41083fbbfedce0563d988b8428e43c7c4c1977a960522

Contents?: true

Size: 1.23 KB

Versions: 11

Compression:

Stored size: 1.23 KB

Contents

require 'zilch/authorisation/nil_user'
require 'refinery/plugins'

module Refinery
  module Core
    class NilUser < Zilch::Authorisation::NilUser
      # The default NilUser has all roles and can access all plugins.
      # Should be overridden in authentication solutions.
      def has_role?(role)
        true
      end

      # Returns all plugins that the user has access to, that are currently
      # loaded in the system.
      # For NilUser, this returns all registered plugins.
      # Should be overridden in authentication solutions
      def active_plugins
        Refinery::Plugins.registered
      end

      # Returns all registered plugins.
      # Should be overridden in authentication solutions.
      def plugins
        Refinery::Plugins.registered
      end

      # Returns true.
      # Should be overridden in authentication solutions.
      # A real solution might be: `Refinery::Plugins.active.names.include?(name)`
      def has_plugin?(name)
        true
      end

      # Returns a URL to the first plugin with a URL in the menu. Used for
      # admin users' root admin url.
      # Should be overridden in authentication solutions.
      def landing_url
        active_plugins.first_url_in_menu
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
refinerycms-core-4.0.3 lib/refinery/core/nil_user.rb
refinerycms-core-4.0.2 lib/refinery/core/nil_user.rb
refinerycms-core-4.0.1 lib/refinery/core/nil_user.rb
refinerycms-core-3.0.6 lib/refinery/core/nil_user.rb
refinerycms-core-4.0.0 lib/refinery/core/nil_user.rb
refinerycms-core-3.0.5 lib/refinery/core/nil_user.rb
refinerycms-core-3.0.4 lib/refinery/core/nil_user.rb
refinerycms-core-3.0.3 lib/refinery/core/nil_user.rb
refinerycms-core-3.0.2 lib/refinery/core/nil_user.rb
refinerycms-core-3.0.1 lib/refinery/core/nil_user.rb
refinerycms-core-3.0.0 lib/refinery/core/nil_user.rb