我正在使用authlogic-example-app,当我注册用户时,我无法从OpenID提供商(在我的情况下是谷歌和雅虎)获得电子邮件地址.我得到一个空响应而不是电子邮件地址(请查看下面代码中的注释).
这就是我的用户模型的样子(其他一切看起来像上面提到的authlogic-example-app的"with_openid" - 分支).除了缺少"电子邮件"之外,openid-authentication-process按预期工作:
class User < ActiveRecord::Base
acts_as_authentic do |c|
# not needed because I use OpenID
c.validate_login_field = false
# avoid failed validation before OpenID request
c.validate_email_field = false
# this one sets 'openid.sreg.required=email'
c.required_fields = [:email]
end
private
# overwriting the existing method in '/lib/authlogic_openid/acts_as_authentic.rb'
def map_openid_registration(registration)
# this is my problem: 'registration' is an empty hash
self.email ||= registration[:email] if respond_to?(:email) && !registration[:email].blank?
end
end
Run Code Online (Sandbox Code Playgroud)
不知道怎么解决这个问题?有没有人在使用authlogic之前完成此操作?甚至更好:你有一个有效的例子吗?
更新:我检查了Google帐户身份验证API,并将authlogic(使用 …
我与omniauth/openid有点混乱.
在尝试进行身份验证时,我在日志中发现了这一点:
OpenID::FetchingError: Error fetching https://www.google.com/accounts/o8/.well-known/host-meta?hd=profiles.google.com%2Fmy_username: undefined method `io' for nil:NilClass
Run Code Online (Sandbox Code Playgroud)
重要的是undefined method io' for nil:NilClass来自openid/fetchers.rb,在下面的代码片段中:
module Net
class HTTP
def post_connection_check(hostname)
check_common_name = true
cert = @socket.io.peer_cert
cert.extensions.each { |ext|
next if ext.oid != "subjectAltName"
ext.value.split(/,\s+/).each{ |general_name|
if /\ADNS:(.*)/ =~ general_name
check_common_name = false
...
Run Code Online (Sandbox Code Playgroud)
该错误是由@socket.io.peer_cert@socket未定义生成的.
你们有没有遇到过这个?不太确定原因是什么.
我正在运行的版本: