oa-recruitmilitary 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Recruitmilitary
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -1,5 +1,3 @@
1
- require 'omniauth/strategies/recruitmilitary'
2
-
3
1
  module OmniAuth
4
2
  module RecruitMilitary
5
3
 
@@ -1,49 +1,52 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
1
+ require 'omniauth-oauth2'
3
2
 
4
3
  module OmniAuth
5
4
  module Strategies
6
- class Recruitmilitary < OAuth2
7
-
8
- def initialize(app, api_key = nil, secret_key = nil, options = {}, &block)
9
- client_options = options.fetch(:client_options, {}).merge(
10
- :site => RecruitMilitary.configuration.site,
11
- :authorize_url => RecruitMilitary.configuration.authorize_url,
12
- :access_token_url => RecruitMilitary.configuration.access_token_url)
13
-
14
- super(app, :recruitmilitary, api_key, secret_key, client_options, &block)
5
+ class Recruitmilitary < ::OmniAuth::Strategies::OAuth2
6
+ option :name, "recruitmilitary"
7
+
8
+ option :client_options, {
9
+ :site => ::OmniAuth::RecruitMilitary.configuration.site,
10
+ :authorize_url => ::OmniAuth::RecruitMilitary.configuration.authorize_url,
11
+ :token_url => ::OmniAuth::RecruitMilitary.configuration.access_token_url,
12
+ }
13
+
14
+ uid{ user_hash['id'] }
15
+
16
+ info do
17
+ {
18
+ :name => user_name,
19
+ :email => user_hash['email'],
20
+ }
15
21
  end
16
22
 
17
- protected
18
-
19
- def user_data
20
- @data ||= MultiJson.decode(@access_token.get(RecruitMilitary.configuration.user_data_url))
23
+ extra do
24
+ {
25
+ 'email' => user_hash['email'],
26
+ 'roles' => user_hash['roles'],
27
+ 'first_name' => user_hash['first_name'],
28
+ 'last_name' => user_hash['last_name'],
29
+ 'military_branch_id' => user_hash['military_branch_id'],
30
+ 'military_status_id' => user_hash['military_status_id'],
31
+ 'gender_id' => user_hash['gender_id'],
32
+ }
21
33
  end
22
34
 
23
- def request_phase
24
- options[:scope] ||= "read"
25
- super
35
+ def raw_info
36
+ @raw_info ||= @access_token.get(RecruitMilitary.configuration.user_data_url).parsed
26
37
  end
27
38
 
28
39
  def user_hash
29
- user_data['user']
40
+ raw_info['user']
30
41
  end
31
42
 
32
- def auth_hash
33
- OmniAuth::Utils.deep_merge(super, {
34
- 'uid' => user_hash["id"],
35
- 'user_info' => user_hash['user_info'],
36
- 'extra' => {
37
- 'email' => user_hash['email'],
38
- 'roles' => user_hash['roles'],
39
- 'first_name' => user_hash['first_name'],
40
- 'last_name' => user_hash['last_name'],
41
- 'military_branch_id' => user_hash['military_branch_id'],
42
- 'military_status_id' => user_hash['military_status_id'],
43
- 'gender_id' => user_hash['gender_id'],
44
- }
45
- })
43
+ def user_name
44
+ [
45
+ user_hash['first_name'],
46
+ user_hash['last_name'],
47
+ ].join(' ')
46
48
  end
49
+
47
50
  end
48
51
  end
49
52
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_dependency 'omniauth', '~> 0.2.6'
22
+ s.add_dependency 'omniauth-oauth2', '~> 1.0.0'
23
23
 
24
24
  s.add_development_dependency 'rspec', '~> 2.6'
25
25
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oa-recruitmilitary
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Guterl
@@ -15,22 +15,22 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-26 00:00:00 Z
18
+ date: 2012-01-27 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: omniauth
21
+ name: omniauth-oauth2
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
25
25
  requirements:
26
26
  - - ~>
27
27
  - !ruby/object:Gem::Version
28
- hash: 27
28
+ hash: 23
29
29
  segments:
30
+ - 1
30
31
  - 0
31
- - 2
32
- - 6
33
- version: 0.2.6
32
+ - 0
33
+ version: 1.0.0
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency