Skip to content

Instantly share code, notes, and snippets.

@jamesdaniels
Created June 26, 2010 01:32
Show Gist options
  • Save jamesdaniels/453672 to your computer and use it in GitHub Desktop.
Save jamesdaniels/453672 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
has_many :simple_oauths, :dependent => :destroy
accepts_nested_attributes_for :simple_oauths
validates_presence_of :username, :unless => :using_sso?
def using_sso?
!simple_oauths.empty?
end
end
class OauthRegistrationController < ApplicationController
processes_oauth_transactions_for :simple_oauths, :through => lambda { User.new }
end
class SimpleOauthsController < ApplicationController
processes_oauth_transactions_for :simple_oauths, :through => lambda { current_user }
end
class SimpleOauths < ActiveRecord::Base
oauth do
provider 'Someone' do
key 'asdf'
secret 'asdf'
site 'https://www.google.com'
authorize_path 'asdf'
access_token_path 'asdf'
request_token_path 'asdfff'
end
provider 'GitHub' do
key 'asdf'
secret 'asdf'
site 'https://www.github.com'
authorize_path 'asdf'
access_token_path 'asdf'
end
provider 'Facebook' do
key 'asdf'
secret 'asdf'
site 'https://www.facebook.com'
authorize_path 'asdf'
access_token_path 'asdf'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment