Sha256: 9c670d31f47e2a7d71437b2ee0db3f200e1121b1ac472d43bad4e762d7849440

Contents?: true

Size: 780 Bytes

Versions: 15

Compression:

Stored size: 780 Bytes

Contents

module Devise
  module Strategies
    # Base strategy for Devise. Responsible for verifying correct scope and
    # mapping.
    class Base < Warden::Strategies::Base

      # Validate strategy. By default will raise an error if no scope or an
      # invalid mapping is found.
      def valid?
        mapping.for.include?(self.class.name.split("::").last.underscore.to_sym)
      end

      # Checks if a valid scope was given for devise and find mapping based on
      # this scope.
      def mapping
        @mapping ||= begin
          raise "You need to give a scope for Devise authentication" unless scope
          raise "You need to give a valid Devise mapping"            unless mapping = Devise.mappings[scope]
          mapping
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
devise-0.5.0 lib/devise/strategies/base.rb
shingara-devise-0.4.3.1 lib/devise/strategies/base.rb
shingara-devise-0.4.3 lib/devise/strategies/base.rb
devise-0.4.3 lib/devise/strategies/base.rb
ramon-devise-0.4.2 lib/devise/strategies/base.rb
devise-0.4.2 lib/devise/strategies/base.rb
devise-0.4.1 lib/devise/strategies/base.rb
devise-0.4.0 lib/devise/strategies/base.rb
devise-0.3.0 lib/devise/strategies/base.rb
devise-0.2.3 lib/devise/strategies/base.rb
devise-0.2.2 lib/devise/strategies/base.rb
devise-0.2.1 lib/devise/strategies/base.rb
devise-0.2.0 lib/devise/strategies/base.rb
devise-0.1.1 lib/devise/strategies/base.rb
devise-0.1.0 lib/devise/strategies/base.rb