omniauth-mapsme 1.0.3 → 1.0.4

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: 8bf188cbd8ce5954c90fe16ab1c73ae8f70f8eda
4
- data.tar.gz: 0686d890cb7c6d6085f1c83c0e9c695559158909
3
+ metadata.gz: 60878dea9c9ac5271ba296199ee84492569496ea
4
+ data.tar.gz: 95f466ca93b9e2ec17143434a4d178123c63198c
5
5
  SHA512:
6
- metadata.gz: bbfd385d2d3b2885cb205b3be5c4f484d387d5694d0f4a7ae5f8ec13104e7b564e8f605666711cee4c82d0bede32c587fb861f1fb7a88f06c8585d8994aa1b32
7
- data.tar.gz: 61626badcbf0f1b5719a348431044e09c35e5c0ecc50c008f322a97da28462840ba90e65f225f041cfd7a68b3fbdb56e0377c04a72de19bb2bc8e80544c6a5ca
6
+ metadata.gz: 00c5c31b1ada72fd7f3385733351e541d2b262cb08748cd5b08aee98a51060437c60890b682c475a85c3d0c6dab431d8b36231b120de9eba78fba937f811c188
7
+ data.tar.gz: 9c826898ff1efa97881230c59f90e987ba80c1a9f232fed680d72140eb74bd63c0e230d3b9afa71e1c4912d1de7e5c6448f7def3e77d961735bc1067dedb57bb
@@ -1,6 +1,6 @@
1
1
  module OmniAuth
2
2
  module MapsMe
3
- VERSION = "1.0.3"
3
+ VERSION = "1.0.4"
4
4
  end
5
5
 
6
6
  module MapsMeToken
@@ -2,12 +2,30 @@ module OmniAuth
2
2
  module Strategies
3
3
  module MapsMeBase
4
4
  MAPSME_BASE = 'https://passport.maps.me'
5
+ MAPSME_DEFAULT_SCOPE = 'read'
6
+ MAPSME_USER_DETAILS = '/user_details/'
5
7
 
6
8
  MAPSME_CLIENT_OPTIONS = {
7
9
  :site => MAPSME_BASE,
8
10
  :authorize_url => "#{MAPSME_BASE}/oauth/authorize",
9
- :token_url => "#{MAPSME_BASE}/oauth/token"
11
+ :token_url => "#{MAPSME_BASE}/oauth/token/"
10
12
  }
13
+
14
+ def extract_name(raw_info)
15
+ first_name = raw_info['first_name']
16
+ last_name = raw_info['last_name']
17
+ username = raw_info['username']
18
+
19
+ if first_name
20
+ if last_name
21
+ "#{first_name} #{last_name}"
22
+ else
23
+ first_name
24
+ end
25
+ else
26
+ username
27
+ end
28
+ end
11
29
  end
12
30
  end
13
31
  end
@@ -24,12 +24,12 @@ module OmniAuth
24
24
 
25
25
  attr_accessor :access_token
26
26
 
27
- uid { raw_info['uid'].to_s }
27
+ uid { raw_info['username'] }
28
28
 
29
29
  info do
30
30
  prune!({
31
31
  'email' => raw_info['email'],
32
- 'name' => raw_info['name']
32
+ 'name' => extract_name(raw_info)
33
33
  })
34
34
  end
35
35
 
@@ -47,12 +47,12 @@ module OmniAuth
47
47
 
48
48
  def authorize_params
49
49
  super.tap do |params|
50
- params[:scope] = 'user mail'
50
+ params[:scope] = MAPSME_DEFAULT_SCOPE
51
51
  end
52
52
  end
53
53
 
54
54
  def raw_info
55
- @raw_info ||= access_token.get('/user').parsed || {}
55
+ @raw_info ||= access_token.get(MAPSME_USER_DETAILS).parsed || {}
56
56
  end
57
57
 
58
58
  def info_options
@@ -10,12 +10,12 @@ module OmniAuth
10
10
 
11
11
  option :client_options, MAPSME_CLIENT_OPTIONS
12
12
 
13
- uid { raw_info['uid'].to_s }
13
+ uid { raw_info['username'] }
14
14
 
15
15
  info do
16
16
  {
17
17
  'email' => raw_info['email'],
18
- 'name' => raw_info['name']
18
+ 'name' => extract_name(raw_info)
19
19
  }
20
20
  end
21
21
 
@@ -25,12 +25,12 @@ module OmniAuth
25
25
 
26
26
  def authorize_params
27
27
  super.tap do |params|
28
- params[:scope] = 'user mail'
28
+ params[:scope] = MAPSME_DEFAULT_SCOPE
29
29
  end
30
30
  end
31
31
 
32
32
  def raw_info
33
- @raw_info ||= access_token.get('/user').parsed || {}
33
+ @raw_info ||= access_token.get(MAPSME_USER_DETAILS).parsed || {}
34
34
  end
35
35
 
36
36
  # Fix omniauth-oauth2 issue https://github.com/intridea/omniauth-oauth2/issues/76
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-mapsme
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Zverev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-16 00:00:00.000000000 Z
11
+ date: 2017-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth