Skip to content

Instantly share code, notes, and snippets.

@bornfree
Created April 19, 2013 07:06
Show Gist options
  • Save bornfree/5418621 to your computer and use it in GitHub Desktop.
Save bornfree/5418621 to your computer and use it in GitHub Desktop.
def add_provider(auth_hash)
unless auth_existing = authorizations.find_by_provider_and_uid(auth_hash["provider"], auth_hash["uid"])
# No auth exists for this provider. Create one and update keys.
auth = Authorization.create :user => self, :provider => auth_hash["provider"], :uid => auth_hash["uid"]
auth.update_access_keys(auth_hash)
else
# Auth already exists but we need to update the access_tokens
auth_existing.update_access_keys(auth_hash)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment