Skip to content

Instantly share code, notes, and snippets.

@mokevnin
Created February 3, 2012 07:15
Show Gist options
  • Select an option

  • Save mokevnin/1728701 to your computer and use it in GitHub Desktop.

Select an option

Save mokevnin/1728701 to your computer and use it in GitHub Desktop.
class FacebookService
class << self
def register_via_google(data)
auth = User::Google.find_by_uid(data.uid)
if auth
return :block if auth.user.blocked?
auth.user.activate! unless auth.user.active?
return :success
end
user = User.find_by_email(data.email)
return :blocked if user.blocked?
unless user
user = UserGoogleRegistrationType.new
user.password = SecureApp.generate_password
end
UserPopulator.via_google(user, data)
user.activate! unless user.active?
auth = user.build_google :uid = data.uid
auth.save!
:success
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment