Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def facebook
- # You need to implement the method below in your model (e.g.
- app/models/user.rb)
- @user = User.from_omniauth(request.env["omniauth.auth"])
- if @user.persisted? ←★なぜfalseになってしまうのか?★
- sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
- set_flash_message(:notice, :success, :kind => "Facebook") if
- is_navigational_format?
- else ←★すべて条件分岐先がelseになってしまう。★
- session["devise.facebook_data"] = request.env["omniauth.auth"]
- redirect_to new_user_registration_url
- end
- end
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement