Sha256: 3afc8fe3cd7aa8d74aaedbf93f03448cbc8f594bff4879b2c8a7ff90ff9fbf63

Contents?: true

Size: 1.95 KB

Versions: 6

Compression:

Stored size: 1.95 KB

Contents

require 'rubygems'
require 'bundler/setup'

require 'openid'

module RubyApp

  module Elements

    module Pages

      module Authentication

        module OpenID

          module Base
            require 'ruby_app/elements/page'
            require 'ruby_app/log'
            require 'ruby_app/request'
            require 'ruby_app/session'

            class BaseAuthenticationPage < RubyApp::Elements::Page

              template_path(:all, File.dirname(__FILE__))

              def initialize(identifier)
                super()

                self.loaded do |element, event|
                  if RubyApp::Request.query.empty?
                    @consumer = ::OpenID::Consumer.new(RubyApp::Session.data, nil)
                    request = @consumer.begin(identifier)
                    self.process_request(request)
                    event.go(request.redirect_url(RubyApp::Request.url, RubyApp::Request.url))
                  else
                    response = @consumer.complete(RubyApp::Request.query, RubyApp::Request.url)
                    case response.status
                      when ::OpenID::Consumer::SUCCESS
                        RubyApp::Session.identity = self.create_identity_from_response(response)
                        RubyApp::Session.pages.pop
                        event.refresh
                      when ::OpenID::Consumer::CANCEL
                        RubyApp::Session.pages.pop
                        event.refresh
                      when ::OpenID::Consumer::FAILURE
                        RubyApp::Log.debug("#{self.class}#loaded response=#{response.inspect}")
                    end
                  end
                end

              end

              def process_request(request)
              end

              def create_identity_from_response(response)
                RubyApp::Session::Identity.new(response.identity_url)
              end

            end

          end

        end

      end

    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
RubyApp-0.0.70 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb
RubyApp-0.0.69 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb
RubyApp-0.0.68 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb
RubyApp-0.0.64 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb
RubyApp-0.0.63 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb
RubyApp-0.0.62 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb