Guest User

Untitled

a guest
Sep 22nd, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1.  
  2. def self.create_from_hash(registration_hash)
  3. unless registration_hash || resigration_hash.empty?
  4. return nil
  5. end
  6.  
  7. provider = registration_hash[:provider]
  8. info = registration_hash[:info]
  9.  
  10. user = User.new
  11.  
  12. if info.password
  13. user.password = info.password
  14. else
  15. user.password = Devise.friendly_token[0,20]
  16. end
  17. user.password_confirmation = user.password
  18.  
  19. if provider == "seznam" || provider == "open_id"
  20. user.email = info.nickname
  21. else
  22. user.email = info.email
  23. end
  24.  
  25. # if data.first_name && info.last_name
  26. # user.first_name = info.first_name if user.first_name.blank?
  27. # user.last_name = info.last_name if user.last_name.blank?
  28. # elsif data.name
  29. # user.full_name = info.name if user.full_name.blank?
  30. # user.first_name = info.name.split(' ')[0] if user.first_name.blank?
  31. # user.last_name = info.name.split(' ')[1] if user.last_name.blank?
  32. # end
  33.  
  34. # twitter: čtverec 48x48; odstranit "_normal" ze stringu pro plnou velikost obrázku
  35. # facebook: čtverec 50x50; dál už se s tím nic nedá dělat
  36. # user.image = info.image if user.image.blank?
  37.  
  38. # user.gender = registration_hash['extra']['gender'] if user.gender.blank?
  39.  
  40. if registration_hash[:skip_confirmation] == true
  41. # user.confirm!
  42. end
  43.  
  44. user
  45. end
Add Comment
Please, Sign In to add comment