0
在我目前正在开发的应用程序,我可以使用Facebook和Google+注册。但是,当我加的能力只是一个普通电子邮件报名,我得到这个错误,我会感激一些帮助,请...Rails注册与多种方式
下面是一些我的代码
#SessionsController
def create
@user = User.from_omniauth(env["omniauth.auth"])
# session[:user_id] = @user.id
# redirect_to root_path
@user = User.find_by_email params[:email]
if @user && @user.authenticate(params[:password])
session[:user_id] = @user.id
redirect_to root_path
else
flash[:alert] = "Wrong email or password"
render :new
end
end
#user.rb
class User < ActiveRecord::Base
has_secure_password
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.provider = auth.provider
user.uid = auth.uid
user.name = auth.info.name
user.email = auth.info.email
user.oauth_token = auth.credentials.token
user.oauth_expires_at = Time.at(auth.credentials.expires_at)
user.image = auth.info.image
user.gender = auth.extra.raw_info.gender
user.location = auth.extra.raw_info.location.name
user.location = auth.extra.raw_info.locale
# user.url = auth_hash['info']['urls'][user.provider.capitalize]
user.save
end
end
所以,当试图使用电子邮件注册,这是发生了什么!
我猜错误来,因为我打电话from_omniauth
和我不是一个合格供应商,我不需要在这种情况下使用。
嗨@BenHawker,感谢您的评论,但我试图建立所有的用户身份验证,而不使用Devise ... –