Sha256: dc2cffdda71b46be168b97349a639721293a3925d1e805b6e8d0e88d5b645b8e

Contents?: true

Size: 783 Bytes

Versions: 9

Compression:

Stored size: 783 Bytes

Contents

module Janus
  module Strategies
    # Base class for writing authentication strategies.
    class Base
      attr_reader :scope, :manager, :request, :cookies, :user

      def initialize(scope, manager) # :nodoc:
        @scope, @manager = scope, manager
        @request, @cookies = manager.request, manager.cookies
      end

      def valid?
        true
      end

      def pass
      end

      def success!(user)
        @user = user
      end

      def success?
        !@user.nil?
      end

      def resource
        @resource ||= scope.to_s.camelize.constantize
      end

      def authenticate!
        raise StandardError.new("You must define the #{self.class.name}#authenticate! method.")
      end

      def auth_method
        :login
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
janus-0.10.1 lib/janus/strategies/base.rb
janus-0.10.0 lib/janus/strategies/base.rb
janus-0.9.1 lib/janus/strategies/base.rb
janus-0.9.0 lib/janus/strategies/base.rb
janus-0.8.1 lib/janus/strategies/base.rb
janus-0.8.0 lib/janus/strategies/base.rb
janus-0.7.0 lib/janus/strategies/base.rb
janus-0.6.0 lib/janus/strategies/base.rb
janus-0.5.0 lib/janus/strategies/base.rb