Created
June 26, 2010 01:32
-
-
Save jamesdaniels/453672 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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