Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
initial working code commit, connects to facebook
- Loading branch information
bhbryant
committed
May 18, 2010
1 parent
bb5cf91
commit 303df96
Showing
9 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
Empty file.
Empty file.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# encoding: utf-8 | ||
require 'devise' | ||
require 'oauth2' | ||
|
||
|
||
require 'devise_oauth2_authenticatable/model' | ||
require 'devise_oauth2_authenticatable/strategy' | ||
require 'devise_oauth2_authenticatable/schema' | ||
require 'devise_oauth2_authenticatable/routes' | ||
#require 'devise_oauth2_authenticatable/controller_filters' | ||
require 'devise_oauth2_authenticatable/view_helpers' | ||
|
||
|
||
module Devise | ||
# Specifies the name of the database column name used for storing | ||
# the oauth UID. Useful if this info should be saved in a | ||
# generic column if different authentication solutions are used. | ||
mattr_accessor :oauth2_uid_field | ||
@@oauth2_uid_field = :oauth2_uid | ||
|
||
# Specifies the name of the database column name used for storing | ||
# the user Facebook session key. Useful if this info should be saved in a | ||
# generic column if different authentication solutions are used. | ||
mattr_accessor :oauth2_token_field | ||
@@oauth2_token_field = :oauth2_token | ||
|
||
# Specifies if account should be created if no account exists for | ||
# a specified Facebook UID or not. | ||
mattr_accessor :oauth2_auto_create_account | ||
@@oauth2_auto_create_account = true | ||
|
||
def self.oauth2_client | ||
@@oauth2_client ||= OAuth2::Client.new(OAUTH2_CONFIG['client_id'], OAUTH2_CONFIG['client_secret'], :site => OAUTH2_CONFIG['authorization_server']) | ||
end | ||
|
||
|
||
def self.session_sign_in_url(request, mapping) | ||
url = URI.parse(request.url) | ||
url.path = "#{mapping.parsed_path}/#{mapping.path_names[:sign_in]}" | ||
url.query = nil | ||
url.to_s | ||
end | ||
|
||
def self.requested_scope | ||
@@requested_scope ||= OAUTH2_CONFIG['requested_scope'] | ||
end | ||
|
||
end | ||
|
||
# Load core I18n locales: en | ||
# | ||
I18n.load_path.unshift File.join(File.dirname(__FILE__), *%w[devise_oauth2_authenticatable locales en.yml]) | ||
|
||
# Add +:facebook_connectable+ strategies to defaults. | ||
# | ||
Devise.add_module(:oauth2_authenticatable, | ||
:strategy => true, | ||
:controller => :sessions, | ||
:model => 'devise_oauth2_authenticatable/model') |
Empty file.
Empty file.
Empty file.