我正在使用open_id_authentication插件进行登录。我能够正确地集成插件,它运行良好。我想检索其他值,如用户的昵称和电子邮件,我无法检索。我使用以下代码但注册字段为空。我在这里做得对吗?。
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