omniauth-seznam-cz 2.0.0 → 2.0.1

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
  SHA256:
3
- metadata.gz: '018c31f6a50bcd7385413b4b063795c231cc8b1ce2115443ca1e1c36f131f2f3'
4
- data.tar.gz: f25ad3bed3294d35898518ffa50f7cb9b53827f26af9b91af513dd9b191950dd
3
+ metadata.gz: c497152b862bf61e21d7bb16f6fafc3de31fda2bee5fbd0527d0bb4fb90d5423
4
+ data.tar.gz: c90372061135d1ed15426edc8a4bf5ff7ab7ac306d0412d65a518ac967364a1b
5
5
  SHA512:
6
- metadata.gz: ff61629cc8b90f6b8e1f8f2ee3cfcfc4b4b94f2eaa56d68dfff883a6376ab5c08dfa153742c350facd64b3b0b572f900a3cab3663310744cbe404cab618ee33c
7
- data.tar.gz: f53ad1c3906ac09e068b12f9768bc8e8359e3f86ed0eae17687e04c4aeaa7b1598c1cff726b1c930ff19429bb3f021ca21da1b55dbb270e8ef8dc6c9bf4fe5d4
6
+ metadata.gz: dbb89cee1b2ad73411d480ab4d23cf6ee3dfe542a13f7f42f2c257e28e6fc6952bcc3ed0e7027acce069155e6527b685eff1efebd6f0077f400200c7bcff36aa
7
+ data.tar.gz: cb2406a98d22dc8d054d72e8fa2862aa9248c86038458958104eeb72ea015ea76309a74156ced00f828b310511ad90c218a4b74940fd957941da50aea003af22
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## 2.0.1 - 2026-12-01
5
+
6
+ ### Fixed
7
+ - `info.email` is the verified `email` from Seznam.cz. Seznam.cz can send an empty `username` and `domain`, which made the email `@`. Without a verified email it falls back to `username@domain`, and it is `nil` when both are missing.
8
+
9
+ ### Changed
10
+ - The specs stub `callback_url`, which omniauth-oauth2 1.9 and later call from `authorize_params`.
11
+
4
12
  ## 2.0.0 - 2026-09-28
5
13
 
6
14
  ### Changed
@@ -10,6 +18,13 @@ All notable changes to this project will be documented in this file.
10
18
  ### Fixed
11
19
  - The user info request uses `snaky: false`, so `raw_info` keeps the original keys from Seznam.cz, such as `contact-phone` and `avatar-url`.
12
20
 
21
+ ## 1.1.0 - 2024-02-17
22
+
23
+ ### Changed
24
+ - Allow any oauth2 version below 2 (was `~> 1.1`).
25
+ - Allow any omniauth-oauth2 version below 2 (was `~> 1.7.1`).
26
+ - Remove the version limits from the development dependencies.
27
+
13
28
  ## 1.0.0 - 2022-01-12
14
29
 
15
30
  ### Added
data/README.md CHANGED
@@ -67,6 +67,8 @@ Here's an example of an authentication hash available in the callback by accessi
67
67
  "raw_info": {
68
68
  "advert_user_id": "100000000000000000000",
69
69
  "domain": "seznam.cz",
70
+ "email": "jan.sterba@seznam.cz",
71
+ "email_verified": true,
70
72
  "firstname": "Jan",
71
73
  "lastname": "Sterba",
72
74
  "message": "ok",
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module SeznamCz
5
- VERSION = '2.0.0'
5
+ VERSION = '2.0.1'
6
6
  end
7
7
  end
@@ -40,7 +40,7 @@ module OmniAuth
40
40
  info do
41
41
  {
42
42
  name: "#{raw_info['firstname']} #{raw_info['lastname']}",
43
- email: "#{raw_info['username']}@#{raw_info['domain']}",
43
+ email: email,
44
44
  firstname: raw_info['firstname'],
45
45
  lastname: raw_info['lastname'],
46
46
  contact_phone: raw_info['contact-phone'],
@@ -62,6 +62,20 @@ module OmniAuth
62
62
 
63
63
  private
64
64
 
65
+ # Seznam.cz now sends the account's email, and username and domain can be empty.
66
+ # An unverified email is never used: an app may sign in the existing user it belongs to.
67
+ # Username and domain make up the account's own Seznam mailbox.
68
+ def email
69
+ return raw_info['email'] if email_verified?
70
+
71
+ mailbox = [raw_info['username'], raw_info['domain']]
72
+ mailbox.join('@') unless mailbox.any? { |part| part.to_s.empty? }
73
+ end
74
+
75
+ def email_verified?
76
+ raw_info['email_verified'] == true && !raw_info['email'].to_s.empty?
77
+ end
78
+
65
79
  def get_scope(params)
66
80
  raw_scope = params[:scope] || DEFAULT_SCOPE
67
81
  scope_list = raw_scope.split.map { |item| item.split(',') }.flatten
@@ -18,6 +18,7 @@ describe OmniAuth::Strategies::SeznamCz do
18
18
  allow(strategy).to receive(:request) do
19
19
  request
20
20
  end
21
+ allow(strategy).to receive(:callback_url).and_return('https://example.com/auth/seznam_cz/callback')
21
22
  end
22
23
  end
23
24
 
@@ -188,4 +189,31 @@ describe OmniAuth::Strategies::SeznamCz do
188
189
  expect(subject.token_params['bad']).to eq(nil)
189
190
  end
190
191
  end
192
+
193
+ describe '#info' do
194
+ let(:raw_info) { { 'firstname' => 'Jan', 'lastname' => 'Novak', 'username' => '', 'domain' => '' } }
195
+
196
+ before do
197
+ allow(subject).to receive(:raw_info) { raw_info }
198
+ end
199
+
200
+ it 'should use the verified email' do
201
+ raw_info.merge!('email' => 'jan.novak@seznam.cz', 'email_verified' => true)
202
+ expect(subject.info[:email]).to eq('jan.novak@seznam.cz')
203
+ end
204
+
205
+ it 'should not use an unverified email' do
206
+ raw_info.merge!('email' => 'jan.novak@example.com', 'email_verified' => false)
207
+ expect(subject.info[:email]).to eq(nil)
208
+ end
209
+
210
+ it 'should make the email from username and domain without a verified email' do
211
+ raw_info.merge!('username' => 'jan.novak', 'domain' => 'seznam.cz', 'email' => 'jan.novak@example.com')
212
+ expect(subject.info[:email]).to eq('jan.novak@seznam.cz')
213
+ end
214
+
215
+ it 'should have no email without one' do
216
+ expect(subject.info[:email]).to eq(nil)
217
+ end
218
+ end
191
219
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-seznam-cz
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Sterba