我想在设计中“注册Twitter”。我正在使用twitter-omniauth
。即使我不需要它,我也无法收到电子邮件。但是设计不允许在没有电子邮件的情况下创建帐户。
User.rb
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create! do |user|
user.email = auth.info.email
user.password = Devise.friendly_token[0,20]
end
end
omniauth_controller.rb
def twitter
auth = env["omniauth.auth"]
@user = User.from_omniauth(request.env["omniauth.auth"])
if @user.persisted?
sign_in_and_redirect @user, :event => :authentication
set_flash_message(:notice, :success, :kind => "Twitter") if is_navigational_format?
else
session["devise.twitter_uid"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
我该怎么办?