devise-multi_auth 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 849b74ed9b30c38c32a2852238fc16be477bcfc1
|
4
|
+
data.tar.gz: acc769b30d431e3d3b1d4f4e4a455aa5811ecb09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0360f20b3bc9ab5773364290744efc13754ac132be6f6667bc94cc875651e943b3f8d33b57282660c44de16cb27bf8a57887c5faccde944c81200a0a3a341b41
|
7
|
+
data.tar.gz: c55c51743249a8221140d13c24388b024e7f2d5ac60b7e6337e6c7eeecc4ea42a9a76568461530aab5f909f3ab565943338a45f59b0d326c59ad3bcf88322664
|
@@ -8,6 +8,8 @@ module Devise::MultiAuth
|
|
8
8
|
client = options.fetch(:client)
|
9
9
|
provider = options.fetch(:provider)
|
10
10
|
where(provider: provider, uid: uid).first!.to_access_token(client: client)
|
11
|
+
rescue ActiveRecord::RecordNotFound
|
12
|
+
raise AccessTokenNotFound.new(provider: provider, uid: uid)
|
11
13
|
end
|
12
14
|
|
13
15
|
def self.find_user_by_provider_and_uid(provider, uid)
|
@@ -22,10 +24,18 @@ module Devise::MultiAuth
|
|
22
24
|
where(provider: provider, uid: uid).includes(:user).first
|
23
25
|
end
|
24
26
|
|
27
|
+
def verified?
|
28
|
+
access_token.present?
|
29
|
+
end
|
30
|
+
|
25
31
|
def to_access_token(config = {})
|
26
32
|
client = config.fetch(:client) { Devise::MultiAuth.oauth_client_for(provider) }
|
27
33
|
tokenizer = config.fetch(:tokenizer) { ::OAuth2::AccessToken.method(:new) }
|
28
|
-
|
34
|
+
if verified?
|
35
|
+
tokenizer.call(client, access_token, refresh_token: refresh_token)
|
36
|
+
else
|
37
|
+
raise AccessTokenUnverified.new(provider: provider, uid: uid)
|
38
|
+
end
|
29
39
|
end
|
30
40
|
end
|
31
41
|
end
|
data/lib/devise/multi_auth.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Devise::MultiAuth
|
2
|
+
class AccessTokenError < RuntimeError
|
3
|
+
def initialize(options = {})
|
4
|
+
provider = options.fetch(:provider)
|
5
|
+
uid = options.fetch(:uid)
|
6
|
+
super("#{message_prefix} provider: #{provider.inspect}, uid: #{uid.inspect}.")
|
7
|
+
end
|
8
|
+
def message_prefix
|
9
|
+
"Unspecified access token error for"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class AccessTokenNotFound < AccessTokenError
|
14
|
+
def message_prefix
|
15
|
+
"Unable to find access token for"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class AccessTokenUnverified < AccessTokenError
|
20
|
+
"Possible access token found but unverified for"
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise-multi_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jeremy.n.friesen@gmail.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- app/services/devise/multi_auth/capture_successful_external_authentication.rb
|
149
149
|
- db/migrate/20140204141526_create_authentications.rb
|
150
150
|
- lib/devise/multi_auth/engine.rb
|
151
|
+
- lib/devise/multi_auth/exceptions.rb
|
151
152
|
- lib/devise/multi_auth/version.rb
|
152
153
|
- lib/devise/multi_auth.rb
|
153
154
|
- lib/devise-multi_auth.rb
|