Skip to content

Commit

Permalink
Share email only when the identity is "active"
Browse files Browse the repository at this point in the history
  • Loading branch information
vrajmohan committed Dec 20, 2024
1 parent 076f430 commit b83e589
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/service_provider_identity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def happened_at
end

def email_address_for_sharing
if IdentityConfig.store.feature_select_email_to_share_enabled && email_address
if IdentityConfig.store.feature_select_email_to_share_enabled && session_uuid && email_address
return email_address
end
user.last_sign_in_email_address
Expand Down
20 changes: 18 additions & 2 deletions spec/models/service_provider_identity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,24 @@
identity.email_address = shared_email_address
end

it 'returns the shared email' do
expect(identity.email_address_for_sharing).to eq(shared_email_address)
context 'when the identity is active' do
before do
identity.session_uuid = SecureRandom.uuid
end

it 'returns the shared email' do
expect(identity.email_address_for_sharing).to eq(shared_email_address)
end
end

context 'when the identity is not active' do
before do
identity.session_uuid = nil
end

it 'returns the last login email' do
expect(identity.email_address_for_sharing).to eq(last_login_email_address)
end
end
end

Expand Down

0 comments on commit b83e589

Please sign in to comment.