devise_facebookable 0.0.0.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Ryan McKillen
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ = devise_facebookable
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 Ryan McKillen. See LICENSE for details.
@@ -0,0 +1,45 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "devise_facebookable"
8
+ gem.summary = "Devise module using the Facebook Graph API for authentication."
9
+ gem.description = "Devise module using the Facebook Graph API for authentication."
10
+ gem.email = "ryan.mckillen@gmail.com"
11
+ gem.homepage = "http://github.com/RyOnLife/devise_facebookable"
12
+ gem.authors = ["Ryan McKillen"]
13
+ # gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ # require 'spec/rake/spectask'
22
+ # Spec::Rake::SpecTask.new(:spec) do |spec|
23
+ # spec.libs << 'lib' << 'spec'
24
+ # spec.spec_files = FileList['spec/**/*_spec.rb']
25
+ # end
26
+
27
+ # Spec::Rake::SpecTask.new(:rcov) do |spec|
28
+ # spec.libs << 'lib' << 'spec'
29
+ # spec.pattern = 'spec/**/*_spec.rb'
30
+ # spec.rcov = true
31
+ # end
32
+
33
+ # task :spec => :check_dependencies
34
+
35
+ # task :default => :spec
36
+
37
+ require 'rake/rdoctask'
38
+ Rake::RDocTask.new do |rdoc|
39
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
+
41
+ rdoc.rdoc_dir = 'rdoc'
42
+ rdoc.title = "devise_facebookable #{version}"
43
+ rdoc.rdoc_files.include('README*')
44
+ rdoc.rdoc_files.include('lib/**/*.rb')
45
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0.pre
@@ -0,0 +1,57 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{devise_facebookable}
8
+ s.version = "0.0.0.pre"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ryan McKillen"]
12
+ s.date = %q{2010-05-16}
13
+ s.description = %q{Devise module using the Facebook Graph API for authentication.}
14
+ s.email = %q{ryan.mckillen@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "devise_facebookable.gemspec",
27
+ "lib/devise_facebookable.rb",
28
+ "lib/devise_facebookable/model.rb",
29
+ "lib/devise_facebookable/routes.rb",
30
+ "lib/devise_facebookable/schema.rb",
31
+ "lib/devise_facebookable/strategy.rb",
32
+ "rails/init.rb",
33
+ "spec/devise_facebookable_spec.rb",
34
+ "spec/spec.opts",
35
+ "spec/spec_helper.rb"
36
+ ]
37
+ s.homepage = %q{http://github.com/RyOnLife/devise_facebookable}
38
+ s.rdoc_options = ["--charset=UTF-8"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = %q{1.3.7}
41
+ s.summary = %q{Devise module using the Facebook Graph API for authentication.}
42
+ s.test_files = [
43
+ "spec/devise_facebookable_spec.rb",
44
+ "spec/spec_helper.rb"
45
+ ]
46
+
47
+ if s.respond_to? :specification_version then
48
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
49
+ s.specification_version = 3
50
+
51
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
+ else
53
+ end
54
+ else
55
+ end
56
+ end
57
+
@@ -0,0 +1,22 @@
1
+ require 'devise'
2
+
3
+ require 'devise_facebookable/schema'
4
+ require 'devise_facebookable/routes'
5
+ require 'devise_facebookable/strategy'
6
+
7
+ module Devise
8
+ mattr_accessor :fb_uid
9
+ @@fb_uid = nil
10
+
11
+ mattr_accessor :fb_oauth_access_token
12
+ @@fb_oauth_access_token = nil
13
+
14
+ mattr_accessor :fb_permissions
15
+ @@fb_permissions = nil
16
+ end
17
+
18
+ Devise.add_module(:facebookable,
19
+ :strategy => true,
20
+ :controller => :sessions,
21
+ :model => 'devise_facebookable/model',
22
+ :routes => :facebookable)
@@ -0,0 +1,45 @@
1
+ require 'devise_imapable/strategy'
2
+ require 'koala'
3
+
4
+ module Devise
5
+ module Models
6
+ module Facebookable
7
+ def self.include(base)
8
+ base.class_eval do
9
+ extend ClassMethods
10
+ attr_accessor :password
11
+ end
12
+ end
13
+
14
+ def clean_up_passwords
15
+ self.password = nil
16
+ end
17
+
18
+ def valid_facebook_authentication?(oauth_access_token)
19
+ graph = Koala::Facebook::GraphAPI.new(oauth_access_token)
20
+ graph.get_object("me")["id"]
21
+ end
22
+
23
+ module ClassMethods
24
+ def authenticate_with_facebook(attributes={})
25
+ return unless attributes[:code].present?
26
+
27
+ oauth = Koala::Facebook::OAuth.new '121822724510409', 'c4af0e2325d2bfed67dcc0655ab90bae', 'http://ryonlife.webhop.net:3000/sessions'
28
+ oauthorized = oauth.get_access_token(params[:code])
29
+
30
+ debugger
31
+
32
+ resource = find_for_facebook_authentication({:fb_uid}) || new(conditions)
33
+
34
+ if resource.try(:valid_facebook_authentication?, attributes[:code])
35
+ resource.new_record? ? create(conditions) : resource
36
+ end
37
+ end
38
+ end
39
+
40
+ def find_for_facebook_authentication(conditions)
41
+ find(:first, :conditions => conditions)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,20 @@
1
+ # ActionController::Routing::RouteSet::Mapper.class_eval do
2
+ # protected
3
+ #
4
+ # def facebookable(routes, mapping)
5
+ # routes.with_options(:controller => 'facebook_sessions', :name_prefix => nil) do |session|
6
+ # session.send(:"new_#{mapping.name}_session", mapping.path_names[:sign_in], :action => 'create', :conditions => {:method => :get})
7
+ # session.send(:"#{mapping.name}_session", mapping.path_names[:sign_in], :action => 'create', :conditions => {:method => :post})
8
+ # session.send(:"destroy_#{mapping.name}_session", mapping.path_names[:sign_out], :action => 'destroy', :conditions => { :method => :get })
9
+ # end
10
+ # end
11
+ # end
12
+
13
+ ActionController::Routing::RouteSet::Mapper.class_eval do
14
+
15
+ protected
16
+
17
+ # reuse the session routes and controller
18
+ alias :facebookable :authenticatable
19
+
20
+ end
@@ -0,0 +1,7 @@
1
+ Devise::Schema.class_eval do
2
+ def facebookable
3
+ apply_schema :fb_uid, Integer
4
+ apply_schema :fb_oauth_access_token, String, :null => null, :default => default
5
+ apply_schema :fb_permissions, Text, :null => null, :default => default
6
+ end
7
+ end
@@ -0,0 +1,21 @@
1
+ require 'devise/strategies/base'
2
+
3
+ module Devise
4
+ module Strategies
5
+ class Facebookable < Base
6
+ def valid?
7
+ params[:controller] == 'sessions' && params[:code] && mapping.to.respond_to?(:authenticate_with_facebook)
8
+ end
9
+
10
+ def authenticate!
11
+ if resource = mapping.to.authenticate_with_facebook(params[:code])
12
+ success!(resource)
13
+ else
14
+ fail(:invalid)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ Warden::Strategies.add(:facebookable, Devise::Strategies::Facebookable)
@@ -0,0 +1 @@
1
+ require "devise_facebookable"
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "DeviseFacebookable" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'devise_facebookable'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: devise_facebookable
3
+ version: !ruby/object:Gem::Version
4
+ hash: -300476567
5
+ prerelease: true
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 0
10
+ - pre
11
+ version: 0.0.0.pre
12
+ platform: ruby
13
+ authors:
14
+ - Ryan McKillen
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-05-16 00:00:00 -07:00
20
+ default_executable:
21
+ dependencies: []
22
+
23
+ description: Devise module using the Facebook Graph API for authentication.
24
+ email: ryan.mckillen@gmail.com
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files:
30
+ - LICENSE
31
+ - README.rdoc
32
+ files:
33
+ - .document
34
+ - .gitignore
35
+ - LICENSE
36
+ - README.rdoc
37
+ - Rakefile
38
+ - VERSION
39
+ - devise_facebookable.gemspec
40
+ - lib/devise_facebookable.rb
41
+ - lib/devise_facebookable/model.rb
42
+ - lib/devise_facebookable/routes.rb
43
+ - lib/devise_facebookable/schema.rb
44
+ - lib/devise_facebookable/strategy.rb
45
+ - rails/init.rb
46
+ - spec/devise_facebookable_spec.rb
47
+ - spec/spec.opts
48
+ - spec/spec_helper.rb
49
+ has_rdoc: true
50
+ homepage: http://github.com/RyOnLife/devise_facebookable
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options:
55
+ - --charset=UTF-8
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">"
71
+ - !ruby/object:Gem::Version
72
+ hash: 25
73
+ segments:
74
+ - 1
75
+ - 3
76
+ - 1
77
+ version: 1.3.1
78
+ requirements: []
79
+
80
+ rubyforge_project:
81
+ rubygems_version: 1.3.7
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: Devise module using the Facebook Graph API for authentication.
85
+ test_files:
86
+ - spec/devise_facebookable_spec.rb
87
+ - spec/spec_helper.rb