File tree Expand file tree Collapse file tree 4 files changed +56
-2
lines changed
Expand file tree Collapse file tree 4 files changed +56
-2
lines changed Original file line number Diff line number Diff line change 11# Changelog
22All notable changes to this project will be documented in this file.
33
4+ ## 0.7.0 - 2019-06-03
5+
6+ ### Added
7+ - Ensure ` info[:email] ` is always verified, and include ` unverified_email `
8+
9+ ### Deprecated
10+ - Nothing.
11+
12+ ### Removed
13+ - Nothing.
14+
15+ ### Fixed
16+ - Nothing.
17+
418## 0.6.1 - 2019-03-07
519
620### Added
Original file line number Diff line number Diff line change 22
33module OmniAuth
44 module GoogleOauth2
5- VERSION = '0.6.1 '
5+ VERSION = '0.7.0 '
66 end
77end
Original file line number Diff line number Diff line change @@ -46,7 +46,8 @@ def authorize_params
4646 info do
4747 prune! (
4848 name : raw_info [ 'name' ] ,
49- email : raw_info [ 'email' ] ,
49+ email : verified_email ,
50+ unverified_email : raw_info [ 'email' ] ,
5051 email_verified : raw_info [ 'email_verified' ] ,
5152 first_name : raw_info [ 'given_name' ] ,
5253 last_name : raw_info [ 'family_name' ] ,
@@ -137,6 +138,10 @@ def get_scope(params)
137138 scope_list . join ( ' ' )
138139 end
139140
141+ def verified_email
142+ raw_info [ 'email_verified' ] ? raw_info [ 'email' ] : nil
143+ end
144+
140145 def get_token_options ( redirect_uri )
141146 { redirect_uri : redirect_uri } . merge ( token_params . to_hash ( symbolize_keys : true ) )
142147 end
Original file line number Diff line number Diff line change 300300 end
301301 end
302302
303+ describe '#info' do
304+ let ( :client ) do
305+ OAuth2 ::Client . new ( 'abc' , 'def' ) do |builder |
306+ builder . request :url_encoded
307+ builder . adapter :test do |stub |
308+ stub . get ( '/oauth2/v3/userinfo' ) { [ 200 , { 'content-type' => 'application/json' } , response_hash . to_json ] }
309+ end
310+ end
311+ end
312+ let ( :access_token ) { OAuth2 ::AccessToken . from_hash ( client , { } ) }
313+ before { allow ( subject ) . to receive ( :access_token ) . and_return ( access_token ) }
314+
315+ context 'with verified email' do
316+ let ( :response_hash ) do
317+ { email : 'something@domain.invalid' , email_verified : true }
318+ end
319+
320+ it 'should return equal email and unverified_email' do
321+ expect ( subject . info [ :email ] ) . to eq ( 'something@domain.invalid' )
322+ expect ( subject . info [ :unverified_email ] ) . to eq ( 'something@domain.invalid' )
323+ end
324+ end
325+
326+ context 'with unverified email' do
327+ let ( :response_hash ) do
328+ { email : 'something@domain.invalid' , email_verified : false }
329+ end
330+
331+ it 'should return nil email, and correct unverified email' do
332+ expect ( subject . info [ :email ] ) . to eq ( nil )
333+ expect ( subject . info [ :unverified_email ] ) . to eq ( 'something@domain.invalid' )
334+ end
335+ end
336+ end
337+
303338 describe '#extra' do
304339 let ( :client ) do
305340 OAuth2 ::Client . new ( 'abc' , 'def' ) do |builder |
You can’t perform that action at this time.
0 commit comments