Advertisement
Guest User

Untitled

a guest
Nov 6th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. def facebook
  2. # You need to implement the method below in your model (e.g.
  3. app/models/user.rb)
  4. @user = User.from_omniauth(request.env["omniauth.auth"])
  5.  
  6. if @user.persisted? ←★なぜfalseになってしまうのか?★
  7. sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
  8. set_flash_message(:notice, :success, :kind => "Facebook") if
  9. is_navigational_format?
  10. else ←★すべて条件分岐先がelseになってしまう。★
  11. session["devise.facebook_data"] = request.env["omniauth.auth"]
  12. redirect_to new_user_registration_url
  13. end
  14. end
  15.  
  16. def self.from_omniauth(auth)
  17. where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
  18. user.email = auth.info.email
  19. user.password = Devise.friendly_token[0,20]
  20. end
  21. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement