2017-06-22 13 views
0

omniauth-facebook gemDeviseとしてFacebook認証を正常に実装しました。しかし、私がしたいのは、Facebookが認証した後、レコードを作成する前にパスワード(とパスワードの確認)を指定できるフォームにリダイレクトすることです。Rails - Facebook Omniauth登録時の追加フィールドの取得

どうすればいいですか?

私のコードでは、宝石のドキュメントに基づいて、かなり標準です:

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController 

    def facebook 
    @user = User.from_omniauth(request.env["omniauth.auth"]) 

    if @user.persisted? 
     sign_in_and_redirect @user, :event => :authentication 
     set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format? 
    else 
     session["devise.facebook_data"] = request.env["omniauth.auth"] 
     redirect_to new_user_registration_url 
    end 
end 

    def failure 
    redirect_to root_path 
    end 
end 

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.username = auth.info.name.downcase.gsub(" ", "")  
    end 
end 
+0

だけでなく、それはomniauthの全体の目的は、あなたがそれを望む理由を、ユーザーは、password..just好奇心覚えておく必要はありませんですか? –

+0

実際には、私は他の分野も欲しいです。彼らの国のような。 – yellowreign

答えて

0

私はそれを正しく理解していた場合、あなたが前にprofileページを埋めるために、ユーザが必要アプリをナビゲートすると、次のようなものが表示されます。

application_controller.rb

def after_sign_in_path_for(resource) 
    resource.profile_complete? ? root_path : user_profile_path(resource) 
end 

Devise Wiki

関連する問題