views:

43

answers:

1

I am using the open_id_authentication plugin for login purpose. I am able to integrate the plugin correctly and it works well. I would like to retrieve additional values like the nickname and email of the user, which I am not able to retrieve. I am using the following code but the registration fields are empty . Am I doing something correctly here?. Can you please help me?

def authenticate_with_open_id(identity_url,
              :required => [ :nickname, :email ],
              :optional => :fullname) do |result, identity_url, registration|
            case result.status
            when :missing
              failed_login "Sorry, the OpenID server couldn't be found"
            when :invalid
              failed_login "Sorry, but this does not appear to be a valid OpenID"
            when :canceled
              failed_login "OpenID verification was canceled"
            when :failed
              failed_login "Sorry, the OpenID verification failed"
            when :successful
              if @current_user = User.find_by_openid_identifier(identity_url)
                assign_registration_attributes!(registration)

                if @current_user.save
                  successful_login
                else
                  failed_login "Your OpenID profile registration failed: " +
                  @current_user.errors.full_messages.to_sentence
                end
              else
                @current_user = User.new
                #@current_user.email = registration[:email]
                logger.info(registration)
                if registration.empty?
                  logger.info("reg empty")
                else
                  logger.info("reg not empty")
                end
                #assign_registration_attributes!(registration)
                #failed_login(@current_user)
              end
            end
          end

Thanks

+1  A: 

The code fragment you've shown, from the that plugin's documentation, is quite old by Rails standards. It's not clear whether this plugin or approach would still work given its age and lack of obvious current support and adoption.

While not quite answering question, if you were willing to consider a better supported approach, you might take a look at Authlogic (the last biggest thing in Rails authentication).

Aside: Devise which is currently attracting a lot of attention in the Rails community doesn't seem to be quite there in terms of OpenID although it looks superb as a framework.

Take a look at the tutorial here and don't miss this episode from the incomparable Railscast series. I've found Authlogic to just work with anything I've tried.

bjg