omniauth-test 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/omniauth/strategies/test.rb +42 -81
- data/lib/omniauth/test/version.rb +1 -1
- metadata +1 -1
@@ -1,84 +1,45 @@
|
|
1
|
-
require 'omniauth
|
1
|
+
require 'omniauth/oauth'
|
2
2
|
require 'multi_json'
|
3
|
-
|
4
|
-
require 'rspec/rails'
|
5
|
-
|
3
|
+
|
6
4
|
module OmniAuth
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
%w[force_login lang screen_name].each do |v|
|
46
|
-
if request.params[v]
|
47
|
-
options[:authorize_params][v.to_sym] = request.params[v]
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
%w[x_auth_access_type].each do |v|
|
52
|
-
if request.params[v]
|
53
|
-
options[:request_params][v.to_sym] = request.params[v]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
if request.params['use_authorize'] == 'true'
|
58
|
-
options[:client_options][:authorize_path] = '/oauth/authorize'
|
59
|
-
else
|
60
|
-
options[:client_options][:authorize_path] = '/oauth/authenticate'
|
61
|
-
end
|
62
|
-
|
63
|
-
old_request_phase
|
64
|
-
end
|
65
|
-
|
66
|
-
private
|
67
|
-
|
68
|
-
def image_url
|
69
|
-
original_url = options[:secure_image_url] ? raw_info['profile_image_url_https'] : raw_info['profile_image_url']
|
70
|
-
case options[:image_size]
|
71
|
-
when 'mini'
|
72
|
-
original_url.sub('normal', 'mini')
|
73
|
-
when 'bigger'
|
74
|
-
original_url.sub('normal', 'bigger')
|
75
|
-
when 'original'
|
76
|
-
original_url.sub('_normal', '')
|
77
|
-
else
|
78
|
-
original_url
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
end
|
5
|
+
module Strategies
|
6
|
+
class Test < OAuth2
|
7
|
+
|
8
|
+
def initialize(app, api_key = nil, secret_key = nil, options = {}, &block)
|
9
|
+
client_options = {
|
10
|
+
:site => 'http://auth.cibplus.com',
|
11
|
+
:authorize_url => "http://auth.cibplus.com/oauth/authorize",
|
12
|
+
:access_token_url => "http://auth.cibplus.com/oauth/token"
|
13
|
+
}
|
14
|
+
super(app, :test, api_key, secret_key, client_options, &block)
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
def user_data
|
20
|
+
#@data ||= MultiJson.decode(@access_token.get("/auth/my_strategy/user.json"))
|
21
|
+
end
|
22
|
+
|
23
|
+
def request_phase
|
24
|
+
options[:scope] ||= "read"
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
def user_hash
|
29
|
+
user_data
|
30
|
+
end
|
31
|
+
|
32
|
+
def auth_hash
|
33
|
+
OmniAuth::Utils.deep_merge(super, {
|
34
|
+
'uid' => user_data["uid"],
|
35
|
+
'user_info' => user_data['user_info'],
|
36
|
+
'extra' => {
|
37
|
+
'admin' => user_data['extra']['admin'],
|
38
|
+
'first_name' => user_data['extra']['first_name'],
|
39
|
+
'last_name' => user_data['extra']['last_name'],
|
40
|
+
}
|
41
|
+
})
|
42
|
+
end
|
83
43
|
end
|
84
|
-
end
|
44
|
+
end
|
45
|
+
end
|