svenfuchs-devise_oauth2_authenticatable 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{svenfuchs-devise_oauth2_authenticatable}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["bhbryant"]
|
@@ -81,7 +81,6 @@ module Devise #:nodoc:
|
|
81
81
|
# * http://oauth2er.pjkh.com/user/populate
|
82
82
|
#
|
83
83
|
def on_before_oauth2_auto_create(oauth2_user_attributes)
|
84
|
-
|
85
84
|
if self.respond_to?(:before_oauth2_auto_create)
|
86
85
|
self.send(:before_oauth2_auto_create, oauth2_user_attributes) rescue nil
|
87
86
|
end
|
@@ -101,7 +100,7 @@ module Devise #:nodoc:
|
|
101
100
|
# end
|
102
101
|
#
|
103
102
|
def on_after_oauth2_connect(oauth2_user_attributes)
|
104
|
-
|
103
|
+
|
105
104
|
if self.respond_to?(:after_oauth2_connect)
|
106
105
|
self.send(:after_oauth2_connect, oauth2_user_attributes) rescue nil
|
107
106
|
end
|
@@ -114,13 +113,13 @@ module Devise #:nodoc:
|
|
114
113
|
self.update_attribute(self.send(:"#{self.class.oauth2_token_field}"), using_token)
|
115
114
|
end
|
116
115
|
end
|
117
|
-
|
116
|
+
|
118
117
|
protected
|
119
118
|
|
120
119
|
# Passwords are always required if it's a new rechord and no oauth_id exists, or if the password
|
121
120
|
# or confirmation are being set somewhere.
|
122
121
|
def password_required?
|
123
|
-
|
122
|
+
|
124
123
|
( new_record? && self.send(:"#{self.class.oauth2_uid_field}").nil? ) || !password.nil? || !password_confirmation.nil?
|
125
124
|
end
|
126
125
|
|
@@ -152,8 +151,8 @@ module Devise #:nodoc:
|
|
152
151
|
# Authenticate a user based on OAuth2 UID.
|
153
152
|
#
|
154
153
|
def authenticate_with_oauth2(oauth2_id, oauth2_token)
|
155
|
-
|
156
|
-
# find user and update access token
|
154
|
+
|
155
|
+
# find user and update access token
|
157
156
|
returning(self.find_for_oauth2(oauth2_id)) do |user|
|
158
157
|
user.update_attributes(:"#{self.oauth2_token_field}" => oauth2_token) unless user.nil?
|
159
158
|
end
|
@@ -162,7 +161,7 @@ module Devise #:nodoc:
|
|
162
161
|
|
163
162
|
protected
|
164
163
|
|
165
|
-
|
164
|
+
|
166
165
|
|
167
166
|
# Find first record based on conditions given (OAuth2 UID).
|
168
167
|
# Overwrite to add customized conditions, create a join, or maybe use a
|
@@ -178,8 +177,8 @@ module Devise #:nodoc:
|
|
178
177
|
def find_for_oauth2(uid, conditions = {})
|
179
178
|
self.send(:"find_by_#{self.oauth2_uid_field}",uid, :conditions => conditions)
|
180
179
|
end
|
181
|
-
|
182
|
-
|
180
|
+
|
181
|
+
|
183
182
|
|
184
183
|
# Contains the logic used in authentication. Overwritten by other devise modules.
|
185
184
|
# In the OAuth2 Connect case; nothing fancy required.
|
@@ -2,23 +2,11 @@ module Devise
|
|
2
2
|
class Engine
|
3
3
|
config.after_initialize do
|
4
4
|
begin
|
5
|
-
|
6
|
-
unless File.exists?(config_file)
|
7
|
-
config_file = Rails.root.join('config', 'oauth2_config.yml')
|
8
|
-
if File.exists?(config_file)
|
9
|
-
puts "Deprecated OAuth2 config file config/oauth2_config.yml. Please use config/oauth.yml instead."
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
Devise::OAUTH2_CONFIG = YAML.load_file(config_file)[Rails.env]
|
14
|
-
|
15
|
-
unless Devise::OAUTH2_CONFIG['user_attributes_path']
|
16
|
-
puts "Your config/oauth2.yml does not seem to contain a user_attributes_path setting. Assuming '/me' for FacebookConnect."
|
17
|
-
Devise::OAUTH2_CONFIG['user_attributes_path'] = '/me'
|
18
|
-
end
|
5
|
+
Devise::OAUTH2_CONFIG ||= YAML.load_file(Rails.root.join('config', 'oauth2.yml'))[Rails.env]
|
19
6
|
rescue
|
20
7
|
puts "Can't load oauth2.yml. You can generate with rails g devise:oauth2_authenticatable"
|
21
8
|
end
|
22
9
|
end
|
23
10
|
end
|
24
11
|
end
|
12
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: svenfuchs-devise_oauth2_authenticatable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- bhbryant
|
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
139
|
requirements: []
|
140
140
|
|
141
141
|
rubyforge_project:
|
142
|
-
rubygems_version: 1.
|
142
|
+
rubygems_version: 1.4.2
|
143
143
|
signing_key:
|
144
144
|
specification_version: 3
|
145
145
|
summary: Implements OAuth2 for Devise
|