deviseを使ったfacebook認証の機能を作っているのですが、ユーザーの名前の取得ができず、代わりにメールアドレスが入ってきてしまいます。
コードは以下のようになっています。
【user.rb】
class User < ActiveRecord::Base
Include default devise modules. Others available are:
:confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :omniauthable
mount_uploader :image, ImageUploader
def self.find_for_oauth(auth)
user = User.where(uid: auth.uid, provider: auth.provider).first
unless user
user = User.create(
uid: auth.uid,
provider: auth.provider,
name: auth.info.name,
email: auth.info.email,
password: Devise.friendly_token[4, 30])
end
end
private
def self.dummy_email(auth)
"#{auth.uid}-#{auth.provider}@example.com"
end
end
【devise.rb】
config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
require 'devise/orm/active_record'
config.case_insensitive_keys = [:email]
config.strip_whitespace_keys = [:email]
config.skip_session_storage = [:http_auth]
config.reconfirmable = true
config.expire_all_remember_me_on_sign_out = true
config.password_length = 8..72
config.reset_password_within = 6.hours
config.sign_out_via = :delete
config.omniauth :facebook, '1615719865370748', '25522a278781856ddb09d14628a2cb40',scope: 'name', info_fields: 'name',scope: 'email', info_fields: 'email'
end
どなたか詳しい方、よろしくお願い申し上げます。
あなたの回答
tips
プレビュー