easy_auth-oauth2 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -7
- data/lib/easy_auth/models/identities/oauth2/base.rb +16 -14
- data/lib/easy_auth/oauth2/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -14,17 +14,13 @@ In your Gemfile add the following:
|
|
14
14
|
gem 'easy_auth-oauth2'
|
15
15
|
```
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
```ruby
|
20
|
-
rake easy_auth-oauth2:install:migrations
|
21
|
-
```
|
22
|
-
|
23
|
-
Then run your migrations.
|
17
|
+
Then follow the general installation instructions for
|
18
|
+
[EasyAuth](https://github.com/dockyard/easy_auth#installation)
|
24
19
|
|
25
20
|
## Authors ##
|
26
21
|
|
27
22
|
[Brian Cardarella](http://twitter.com/bcardarella)
|
23
|
+
[Dan McClain](http://twitter.com/_danmcclain)
|
28
24
|
|
29
25
|
## Versioning ##
|
30
26
|
|
@@ -9,21 +9,23 @@ module EasyAuth::Models::Identities::Oauth2::Base
|
|
9
9
|
|
10
10
|
module ClassMethods
|
11
11
|
def authenticate(controller)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
if controller.params[:code].present? && controller.params[:error].blank?
|
13
|
+
callback_url = controller.oauth2_callback_url(:provider => provider)
|
14
|
+
code = controller.params[:code]
|
15
|
+
token = client.auth_code.get_token(code, token_options(callback_url))
|
16
|
+
user_info = get_user_info(token)
|
17
|
+
identity = self.find_or_initialize_by_username user_info['id'].to_s
|
18
|
+
identity.token = token.token
|
19
|
+
account = controller.current_account
|
20
|
+
|
21
|
+
if identity.new_record?
|
22
|
+
account = EasyAuth.account_model.create(EasyAuth.account_model.identity_username_attribute => identity.username) if account.nil?
|
23
|
+
identity.account = account
|
24
|
+
end
|
25
|
+
|
26
|
+
identity.save!
|
27
|
+
identity
|
23
28
|
end
|
24
|
-
|
25
|
-
identity.save!
|
26
|
-
identity
|
27
29
|
end
|
28
30
|
|
29
31
|
def new_session(controller)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_auth-oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-11-
|
13
|
+
date: 2012-11-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: easy_auth
|
@@ -177,7 +177,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
177
|
version: '0'
|
178
178
|
segments:
|
179
179
|
- 0
|
180
|
-
hash: -
|
180
|
+
hash: -1473449787249200133
|
181
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
182
|
none: false
|
183
183
|
requirements:
|
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
186
|
version: '0'
|
187
187
|
segments:
|
188
188
|
- 0
|
189
|
-
hash: -
|
189
|
+
hash: -1473449787249200133
|
190
190
|
requirements: []
|
191
191
|
rubyforge_project:
|
192
192
|
rubygems_version: 1.8.23
|