Ryan Bates のエピソードを見て、omniauth でデバイスを使用しました。問題は、linkdin でサインアップできることです。私のコード
私のuser.rbで
field :provider, :type => String
field :uid, :type => String
field :name, :type => String
#has_many :authentications
def self.from_omniauth(auth)
where(auth.slice("provider", "uid")).first || create_from_omniauth(auth)
end
def self.create_from_omniauth(auth)
create! do |user|
user.provider = auth["provider"]
user.uid = auth["uid"]
user.name = auth["info"]["nickname"]
end
end
これを追加し、認証用の作成コントローラーで行いました
user = User.from_omniauth(env["omniauth.auth"])
session[:user_id] = user.id
redirect_to root_url, notice: "Signed in!"
ユーザーデータベースにlinkdinの値を入れることに成功しました
{ "_id" : ObjectId("50b2f4e66d7ab88ac7000003"), "email" : "", "encrypted_password" : "", "sign_in_count" : 0, "provider" : "linkedin", "uid" : "wuBFLcbDyB", "name" : null, "updated_at" : ISODate("2012-11-26T04:49:42.549Z"), "created_at" : ISODate("2012-11-26T04:49:42.549Z") }
しかし、linkdinからログインすると、linkdinを介してサインアップしません。それ以外の場合はリダイレクトされます
http://localhost:3000/users/sign_in
そのlinkdinを介してログインするにはどうすればよいですか?