devise_facebook_connectable 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,13 @@ module Devise #:nodoc:
9
9
  #
10
10
  module Filters
11
11
 
12
+ # == References
13
+ #
14
+ # For more info about the available Facebooker controller methods:
15
+ #
16
+ # * http://github.com/mmangino/facebooker/blob/master/lib/facebooker/rails/controller.rb
17
+ #
18
+
12
19
  def self.included(base) #:nodoc:
13
20
  base.class_eval do
14
21
  before_filter :expired_session_hack
@@ -24,7 +31,12 @@ module Devise #:nodoc:
24
31
  def expired_session_hack
25
32
  clear_facebook_session_information
26
33
  rescue
27
- # rescue in ruby 1.9
34
+ if RUBY_VERSION >= '1.9' && RAILS_GEM_VERSION == '2.3.4'
35
+ # Rails 2.3.4 on Ruby 1.9 issue. Should not happen in Rails 2.3.5+
36
+ # See: https://rails.lighthouseapp.com/projects/8994/tickets/3144
37
+ raise "Error caused by a known session handling bug in Rails 2.3.4 on Ruby 1.9." <<
38
+ " Please try to install Rails 2.3.5+ to be on the safe side."
39
+ end
28
40
  end
29
41
 
30
42
  # Handle expired Facebook sessions automatically.
@@ -16,7 +16,7 @@ module Devise #:nodoc:
16
16
  # Without a Facebook session authentication cannot proceed.
17
17
  #
18
18
  def valid?
19
- ::Facebooker::Session.current.present?
19
+ super && ::Facebooker::Session.current.present?
20
20
  end
21
21
 
22
22
  # Authenticate user with Facebook Connect.
@@ -42,7 +42,7 @@ module Devise #:nodoc:
42
42
  end
43
43
 
44
44
  begin
45
- user.save_with_validation(false)
45
+ user.save(false)
46
46
  user.on_after_facebook_connect(facebook_session)
47
47
  success!(user)
48
48
  rescue
@@ -32,28 +32,28 @@ module Devise #:nodoc:
32
32
 
33
33
  # Convenient sign in/out (connect) method. See below.
34
34
  #
35
- def facebook_link(options = {})
36
- scope = auto_detect_scope(options.slice(:scope, :for))
37
- options.except!(:scope, :for)
38
-
35
+ def facebook_link(*args)
36
+ scope = auto_detect_scope(*args)
39
37
  unless signed_in?(scope)
40
- facebook_sign_in_link(options.merge(:scope => scope))
38
+ facebook_sign_in_link(*args)
41
39
  else
42
- facebook_sign_out_link(options.merge(:scope => scope))
40
+ facebook_sign_out_link(*args)
43
41
  end
44
42
  end
45
43
 
46
44
  # Deprecated in favor for +facebook_sign_in_link+.
47
45
  #
48
46
  def facebook_login_link(options = {})
49
- ::ActiveSupport::Deprecation.warn("facebook_login_link is deprecated. Use: facebook_sign_in_link")
47
+ ::ActiveSupport::Deprecation.warn("DEPRECATION:" <<
48
+ " facebook_login_link is deprecated. Use: facebook_sign_in_link.")
50
49
  facebook_sign_in_link(options)
51
50
  end
52
51
 
53
52
  # Deprecated in favor for +facebook_sign_in_link+.
54
53
  #
55
54
  def facebook_logout_link(options = {})
56
- ::ActiveSupport::Deprecation.warn("facebook_logout_link is deprecated. Use: facebook_sign_out_link")
55
+ ::ActiveSupport::Deprecation.warn("DEPRECATION:" <<
56
+ " facebook_logout_link is deprecated. Use: facebook_sign_out_link.")
57
57
  facebook_sign_out_link(options)
58
58
  end
59
59
 
@@ -67,7 +67,8 @@ module Devise #:nodoc:
67
67
  # then this is the same as a traditional "create account".
68
68
  #
69
69
  def facebook_sign_in_link(options = {})
70
- scope = auto_detect_scope(options.slice(:scope, :for))
70
+ scope = auto_detect_scope(*args)
71
+ options = args.extract_options!
71
72
  options.except!(:scope, :for)
72
73
  options.reverse_merge!(
73
74
  :label => ::I18n.t(:sign_in, :scope => [:devise, :sessions, :facebook_actions]),
@@ -93,8 +94,9 @@ module Devise #:nodoc:
93
94
  # Agnostic Facebook Connect sign_out button/link. Logs out the current
94
95
  # user from both the app/site and Facebook main site (for security reasons).
95
96
  #
96
- def facebook_sign_out_link(options = {})
97
- scope = auto_detect_scope(options.slice(:scope, :for))
97
+ def facebook_sign_out_link(*args)
98
+ scope = auto_detect_scope(*args)
99
+ options = args.extract_options!
98
100
  options.except!(:scope, :for)
99
101
  options.reverse_merge!(
100
102
  :label => ::I18n.t(:sign_out, :scope => [:devise, :sessions, :facebook_actions]),
@@ -114,7 +116,7 @@ module Devise #:nodoc:
114
116
  end
115
117
  end
116
118
 
117
- # Agnostic Facebook Connect disconnect button/link.
119
+ # TODO: Agnostic Facebook Connect disconnect button/link.
118
120
  # Disconnects, i.e. deletes, user account. Identical as "Delete my account",
119
121
  # but for Facebook Connect (which "un-installs" the app/site for the current user).
120
122
  #
@@ -139,16 +141,25 @@ module Devise #:nodoc:
139
141
  # Used to make the link-helpers smart if - like in most cases -
140
142
  # only one devise scope will be used, e.g. "user" or "account".
141
143
  #
142
- def auto_detect_scope(options = {})
143
- scope = options[:scope] || options[:for]
144
+ def auto_detect_scope(*args)
145
+ options = args.extract_options!
146
+
147
+ if options.key?(:for)
148
+ options[:scope] = options[:for]
149
+ ::ActiveSupport::Deprecation.warn("DEPRECATION: " <<
150
+ "Devise scope :for option is deprecated. " <<
151
+ "Use: facebook_*_link(:some_scope), or facebook_*_link(:scope => :some_scope)")
152
+ end
153
+
154
+ scope = args.detect { |arg| arg.is_a?(Symbol) } || options[:scope]
144
155
  scope ||= ::Warden::Manager.default_scope
145
- mapping = ::Devise::Mapping.new(scope, {})
146
-
156
+ mapping = ::Devise.mappings[scope]
157
+
147
158
  if mapping.for.include?(:facebook_connectable)
148
159
  scope
149
160
  else
150
161
  error_message =
151
- "devise/facebook_connectable: %s" <<
162
+ "%s" <<
152
163
  " Did you forget to devise facebook_connect in your model? Like this: devise :facebook_connectable." <<
153
164
  " You can also specify scope explicitly, e.g.: facebook_*link :for => :customer."
154
165
  error_message %=
@@ -156,7 +167,7 @@ module Devise #:nodoc:
156
167
  "#{scope.inspect} is not a valid facebook_connectable devise scope. " <<
157
168
  "Loaded modules for this scope: #{mapping.for.inspect}."
158
169
  else
159
- "Could not auto-detect any facebook_connectable devise-model."
170
+ "Could not auto-detect any facebook_connectable devise scope."
160
171
  end
161
172
  raise error_message
162
173
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_facebook_connectable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Grimfelt
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-16 00:00:00 +01:00
12
+ date: 2010-01-08 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency