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?.

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
4

1 回答 1

1

您从该插件的文档中显示的代码片段按照 Rails 标准来说已经很老了。鉴于其年代久远且当前缺乏明显的支持和采用,尚不清楚该插件或方法是否仍然有效。

虽然没有完全回答问题,但如果您愿意考虑一种更好的支持方法,您可以看看Authlogic(Rails 身份验证中最重要的事情)。

旁白:目前在Rails社区中引起很多关注的设计在 OpenID 方面似乎并不完全存在,尽管它作为一个框架看起来很棒。

看看这里的教程,不要错过无与伦比的Railscast系列的这一集。我发现 Authlogic只适用于我尝试过的任何东西。

于 2010-07-16T00:01:59.007 回答