Sha256: bf727c17996392a83501a7a00aa0594ee55e8cedaac8078e615331bda0ae95d7

Contents?: true

Size: 1.93 KB

Versions: 13

Compression:

Stored size: 1.93 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|

                  unless @consumer
                    @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.go('/')
                      when ::OpenID::Consumer::CANCEL
                        RubyApp::Session.pages.pop
                        event.go('/')
                      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

13 entries across 13 versions & 1 rubygems

Version Path
RubyApp-0.0.91 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb
RubyApp-0.0.90 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb
RubyApp-0.0.89 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb
RubyApp-0.0.88 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb
RubyApp-0.0.87 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb
RubyApp-0.0.86 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb
RubyApp-0.0.85 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb
RubyApp-0.0.84 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb
RubyApp-0.0.83 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb
RubyApp-0.0.82 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb
RubyApp-0.0.81 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb
RubyApp-0.0.80 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb
RubyApp-0.0.79 lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb