Do you run a Rails website that allows traditional username/email/password login and OpenID authentication? Do you know for sure that your “remember me” feature is working? Please do check…I’ll wait…

Good, now that you realize your “remember me” feature is not working for the OpenID login on your site, I’ll show you an easy way to hack it into the latest version of the open_id_authentication plugin. My preferred method to hack plugins is the evil twin technique.

The basic problem here is that your login form’s parameter list is not being passed back to your application after authenticity is checked at the OpenID provider. You have a remember_me checkbox, and, dammit, you want that parameter passed through. (Program note: some say this is not proper technique. I’m just trying to get you a solution, however temporary that may be.)

We need to hack the opend_id_redirect_url method:

def open_id_redirect_url(open_id_request, return_to = nil)
  open_id_request.return_to_args['open_id_complete'] = '1'
  open_id_request.redirect_url(root_url, return_to || requested_url)

Using the evil twin technique, create an “open_id_authentication_hacks” folder in your vendor/plugins directory. Within this directory, create an “init.rb” file and add the following:

OpenIdAuthentication.module_eval do


  def open_id_redirect_url_with_remember_me(open_id_request, return_to = nil)
    open_id_request.return_to_args['remember_me'] = params['remember_me']
    open_id_redirect_url_without_remember_me(open_id_request, return_to)
  alias_method_chain :open_id_redirect_url, :remember_me


Now you have a nicely aliased method that includes the remember_me parameter upon returning to your app.

Jun 30, 2008 · Subscribe · Archive · Projects · Twitter · GitHub · Flickr