Commit 4ea758a15d5edb913dbb829ab9c2a1a882b95423

  • Tree SHA1: 6cf7c00
  • Parent SHA1: 4e3fbf5 (Refactorize session authentication methods. Support calling them from other controllers beyond SessionsController)
  • raw diff | raw patch
Scaffold OpenIdOwningsController
  
1class OpenIdOwningsController < ApplicationController
2 include ActionController::Sessions::Openid
3
4 authentication_filter
5
6 def create
7 session[:openid_return_to] = request.referer || url_for(:action => 'index', :only_path => false)
8 create_session_with_openid
9
10 unless performed?
11 redirect_to request.referer || { :action => 'index' }
12 end
13 end
14
15 def destroy
16 open_id_owning.destroy
17
18 redirect_to request.referer || { :action => 'index' }
19 end
20
21 private
22
23 def open_id_owning
24 @open_id_owning ||= current_agent.openid_ownings.find(params[:id])
25 end
26end
  
1<html>
2 <body>
3 <%= @form_text %>
4 </body>
5</html>
  
2929 :reset_password_code => nil
3030 end
3131
32 if ActiveRecord::Agent::authentication_classes(:openid).any?
33 map.resources :open_id_ownings
34 end
35
3236 map.resources :categories
3337 map.resources :tags
3438
  
3434 # papereq = ::OpenID::PAPE::Request.new
3535 # ...
3636
37 if openid_request.send_redirect?(options[:realm], options[:return_to])
38 redirect_to openid_request.redirect_url(options[:realm], options[:return_to])
37 if openid_request.send_redirect?(options[:realm], open_id_complete_url)
38 redirect_to openid_request.redirect_url(options[:realm], open_id_complete_url)
3939 else
4040 #FIXME: create
41 @form_text = openid_request.form_markup(realm, return_to, true, { 'id' => 'openid_form' })
42 render :layout => nil
41 @form_text = openid_request.form_markup(options[:realm], open_id_complete_url, true, { 'id' => 'openid_form' })
42 render :partial => 'sessions/openid_form', :layout => nil
4343 end
4444 # OpenID login completion
4545 elsif params[:open_id_complete]
4646 # Filter path parameters
4747 parameters = params.reject{ |k,v| request.path_parameters[k] }
4848 # Complete the OpenID verification process
49 openid_response = openid_consumer.complete(parameters, options[:return_to])
49 openid_response = openid_consumer.complete(parameters, open_id_complete_url)
5050
5151 case openid_response.status
5252 when ::OpenID::Consumer::SUCCESS
5656 # If already authenticated, add URI to Agent.openid_ownings
5757 if authenticated? && ! current_agent.openid_uris.include?(uri)
5858 current_agent.openid_uris << uri
59 flash[:notice] = t(:id_attached_to_account, :id => uri)
60 return current_agent
59 flash[:success] = t('openid.client.id_attached_to_account', :id => uri)
60
61 if session[:openid_return_to].present?
62 redirect_to session.delete(:openid_return_to)
63 return
64 else
65 return current_agent
66 end
6167 end
6268
6369 ActiveRecord::Agent.authentication_classes(:openid).each do |klass|