Sha256: b8138277e956438fd5e9a5c6e52d8890ce18a09dc657a7ac64c015217a9327b5

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

module Passport
  module Certification
    def self.included(base)
      base.extend ClassMethods
    end
    
    module ClassMethods
      def process?
        Passport::Oauth::Protocol.request?# || Passport::OpenId::Protocol.start?
      end
      alias start? process?
    
      def process(user = nil)
        protocol.process(user) if protocol
      end
      alias start process
      
      def approve?
        Passport::Oauth::Protocol.response? # || Passport::OpenId::Protocol.complete?
      end
      alias complete? approve?
      
      def approve(user = nil)
        protocol.approve(user) if protocol
      end
      alias complete approve
      
      def authenticate(user = nil, &block)
        if process?
          process(user) # redirect to service
        elsif approve?
          token = approve(user)
          yield(token) if block_given?
          token
        end
      end
      
      def protocol
        if Passport::Oauth::Protocol.active?
          Passport::Oauth::Protocol
        # elsif Passport::OpenId::Protocol.using?
          #Passport::OpenId::Protocol
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
passport-0.1.1 lib/passport/core/certification.rb