Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 9214

Show
Ignore:
Timestamp:
04/02/08 15:15:11 (8 months ago)
Author:
josh
Message:

OpenID Authentication plugin: Allow a return_to option to be used instead of the requested url.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/open_id_authentication/CHANGELOG

    r9103 r9214  
     1* Allow a return_to option to be used instead of the requested url [Josh Peek] 
     2 
    13* Updated plugin to use Ruby OpenID 2.x.x [Josh Peek] 
    24 
  • plugins/open_id_authentication/lib/open_id_authentication.rb

    r9207 r9214  
    8282    end 
    8383 
    84     def authenticate_with_open_id(identity_url = params[:openid_url], fields = {}, &block) #:doc: 
     84    def authenticate_with_open_id(identity_url = params[:openid_url], options = {}, &block) #:doc: 
    8585      if params[:open_id_complete].nil? 
    86         begin_open_id_authentication(normalize_url(identity_url), fields, &block) 
     86        begin_open_id_authentication(normalize_url(identity_url), options, &block) 
    8787      else 
    8888        complete_open_id_authentication(&block) 
     
    9191 
    9292  private 
    93     def begin_open_id_authentication(identity_url, fields = {}) 
     93    def begin_open_id_authentication(identity_url, options = {}) 
     94      return_to = options.delete(:return_to) 
    9495      open_id_request = open_id_consumer.begin(identity_url) 
    95       add_simple_registration_fields(open_id_request, fields) 
    96       redirect_to(open_id_redirect_url(open_id_request)) 
     96      add_simple_registration_fields(open_id_request, options) 
     97      redirect_to(open_id_redirect_url(open_id_request, return_to)) 
    9798    rescue OpenID::OpenIDError, Timeout::Error => e 
    9899      logger.error("[OPENID] #{e}") 
     
    141142    end 
    142143 
    143     def open_id_redirect_url(open_id_request
     144    def open_id_redirect_url(open_id_request, return_to = nil
    144145      open_id_request.return_to_args['open_id_complete'] = '1' 
    145       open_id_request.redirect_url(root_url, requested_url) 
     146      open_id_request.redirect_url(root_url, return_to || requested_url) 
    146147    end 
    147148