Class: RubyApp::Elements::Pages::Authentication::OpenID::Base::BaseAuthenticationPage

Inherits:
RubyApp::Elements::Page show all
Defined in:
lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb

Direct Known Subclasses

AuthenticationPage

Instance Attribute Summary

Attributes inherited from Base::BasePage

#interval

Attributes inherited from RubyApp::Element

#attributes

Instance Method Summary collapse

Methods inherited from RubyApp::Element

#element_id, get_element

Methods included from Mixins::ConfigureMixin

#configure

Methods included from Mixins::TranslateMixin

#localize, #translate

Methods included from Mixins::TemplateMixin

#exclude_parent_template, #exclude_parent_template?, #get_templates, #template_name, #template_path

Methods included from Mixins::RenderMixin

#clear_content_for, #content_for, #render, #rendered?

Constructor Details

#initialize(identifier) ⇒ BaseAuthenticationPage



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb', line 26

def initialize(identifier)
  super()

  self.loaded do |element, event|
    if RubyApp::Request.query.empty?
      @consumer = ::OpenID::Consumer.new(RubyApp::Session.data, nil)
      RubyApp::Log.debug("#{self.class}#loaded identifier=#{identifier.inspect}")
      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)
      RubyApp::Log.debug("#{self.class}#loaded response.class=#{response.class}")
      case response.status
        when ::OpenID::Consumer::SUCCESS
          RubyApp::Log.debug("#{self.class}#loaded response.identity_url=#{response.identity_url.inspect}")
          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

Instance Method Details

#create_identity_from_response(response) ⇒ Object



59
60
61
# File 'lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb', line 59

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

#process_request(request) ⇒ Object



56
57
# File 'lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb', line 56

def process_request(request)
end