Class: UzuUzu::Controller::Openid

Inherits:
Object
  • Object
show all
Defined in:
lib/uzuuzu-cms/controller/openid.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



18
19
20
21
22
23
24
25
26
# File 'lib/uzuuzu-cms/controller/openid.rb', line 18

def index
  if session[:openid_identity]
    referer = session[:referer]
    session.delete(:referer)
    redirect referer || rf(Index)
  end
  session[:referer] = request.referrer
  respond(render_page(info, render_file(__DIR__('view/openid/index.rhtml'))))
end

#logoutObject



28
29
30
31
32
# File 'lib/uzuuzu-cms/controller/openid.rb', line 28

def logout
  session.delete(:openid_identity)
  session.delete(:openid_sreg)
  session.delete(:openid_domain)
end

#openid_beginObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/uzuuzu-cms/controller/openid.rb', line 34

def openid_begin
  url = request.params['url']
  redirect_referrer if url.to_s.empty?
  session[:openid_domain] = url
  session[:openid_entry] = request.referrer

  openid_request = openid_consumer.begin(url)

  papereq = OpenID::PAPE::Request.new
  papereq.add_policy_uri(OpenID::PAPE::AUTH_PHISHING_RESISTANT)
  papereq.max_auth_age = 2*60*60
  openid_request.add_extension(papereq)

  sregreq = OpenID::SReg::Request.new
  sregreq.request_fields(['fullname', 'nickname', 'dob', 'email',
                         'gender', 'postcode', 'country', 'language',
                         'timezone'])
  openid_request.add_extension(sregreq)
  openid_request.return_to_args['did_pape'] = 'y'

  root      = root_uri
  return_to = "#{root_uri}#{r(:openid_complete)}"
  immediate = false

  if openid_request.send_redirect?(root, return_to, immediate)
    redirect_url =
      openid_request.redirect_url(root, return_to, immediate)
    redirect redirect_url
  else
    # what the hell is @form_text ?
  end
rescue OpenID::OpenIDError => ex
  server_error
end

#openid_completeObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/uzuuzu-cms/controller/openid.rb', line 69

def openid_complete
  openid_response = openid_consumer.complete(request.params, request.url)

  case openid_response.status
  when OpenID::Consumer::FAILURE
  when OpenID::Consumer::SUCCESS
    # Backwards compatibility
    session[:openid_identity] = openid_response.identity_url
    session[:openid_sreg] = OpenID::SReg::Response.from_success_response(openid_response)
  end
  openid_entry = session[:openid_entry]
  session.delete(:openid_entry)
  redirect openid_entry
end