omniauth-microsoft-office365 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1709f398346ffb52d4477645cc2d7fd289490a4d
|
4
|
+
data.tar.gz: f7d8ab0dc27ba6ab11947611f46e5aef48a2658d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52dd89caac47c6ec88794c0b96d7bc0da6f1194890b7a92e6027ccae9ebd39af7f06502ce67f1662ef418c616bb181a63a97c53b0de7f07f7d0d21b2d5e26448
|
7
|
+
data.tar.gz: dc8289cbe82684efaa699f3a4bad02f12989f80fb939f398a816567bee1c3dea1eae73df20206da8aa30cde08e52b274cbc7d0a5f2ed1aa8aad28ec57c7f4ce5
|
@@ -21,8 +21,8 @@ module OmniAuth
|
|
21
21
|
{
|
22
22
|
email: raw_info["EmailAddress"],
|
23
23
|
display_name: raw_info["DisplayName"],
|
24
|
-
first_name: raw_info["DisplayName"]
|
25
|
-
last_name: raw_info["DisplayName"]
|
24
|
+
first_name: first_last_from_display_name(raw_info["DisplayName"])[0],
|
25
|
+
last_name: first_last_from_display_name(raw_info["DisplayName"])[1],
|
26
26
|
image: avatar_file,
|
27
27
|
alias: raw_info["Alias"]
|
28
28
|
}
|
@@ -40,6 +40,15 @@ module OmniAuth
|
|
40
40
|
|
41
41
|
private
|
42
42
|
|
43
|
+
def first_last_from_display_name(display_name)
|
44
|
+
# For display names with last name first like "Del Toro, Benicio"
|
45
|
+
if last_first = display_name.match(/^([^,]+),\s+(\S+)$/)
|
46
|
+
[last_first[2], last_first[1]]
|
47
|
+
else
|
48
|
+
display_name.split(/\s+/, 2)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
43
52
|
def callback_url
|
44
53
|
options[:redirect_uri] || (full_host + script_name + callback_path)
|
45
54
|
end
|
@@ -57,6 +66,8 @@ module OmniAuth
|
|
57
66
|
rescue ::OAuth2::Error => e
|
58
67
|
if e.response.status == 404 # User has no avatar...
|
59
68
|
return nil
|
69
|
+
elsif e.code['code'] == 'GetUserPhoto' && e.code['message'].match('not supported')
|
70
|
+
nil
|
60
71
|
else
|
61
72
|
raise
|
62
73
|
end
|
@@ -131,6 +131,38 @@ RSpec.describe OmniAuth::Strategies::MicrosoftOffice365 do
|
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
+
context "when the name is in alternate format" do
|
135
|
+
let(:avatar_response) { instance_double(OAuth2::Response, content_type: "image/jpeg", body: "JPEG_STREAM") }
|
136
|
+
|
137
|
+
before do
|
138
|
+
expect(access_token).to receive(:get).with("https://outlook.office.com/api/v2.0/me/photo/$value")
|
139
|
+
.and_return(avatar_response)
|
140
|
+
end
|
141
|
+
|
142
|
+
let(:profile_response) do
|
143
|
+
instance_double(OAuth2::Response, parsed: {
|
144
|
+
"@odata.context" => "https://outlook.office.com/api/v2.0/$metadata#Me",
|
145
|
+
"@odata.id" => "https://outlook.office.com/api/v2.0/Users('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX@XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX')",
|
146
|
+
"Id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX@XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
|
147
|
+
"EmailAddress" => "luke.skywalker@example.com",
|
148
|
+
"DisplayName" => "Luke Skywalker",
|
149
|
+
"Alias" => "luke.skywalker",
|
150
|
+
"MailboxGuid" => "YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY"
|
151
|
+
})
|
152
|
+
end
|
153
|
+
|
154
|
+
it "returns the parsed first and last name correctly" do
|
155
|
+
expect(strategy.info).to match({
|
156
|
+
alias: "luke.skywalker",
|
157
|
+
display_name: "Luke Skywalker",
|
158
|
+
email: "luke.skywalker@example.com",
|
159
|
+
first_name: "Luke",
|
160
|
+
last_name: "Skywalker",
|
161
|
+
image: Tempfile,
|
162
|
+
})
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
134
166
|
context "when user didn't provide avatar image" do
|
135
167
|
let(:avatar_response) { instance_double(OAuth2::Response, "error=" => nil, status: 404, parsed: {}, body: '') }
|
136
168
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-microsoft-office365
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Urbański
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|