Skip to content

Commit

Permalink
FIX: Do not raise exception if the authenticator email is missing
Browse files Browse the repository at this point in the history
Followup to 296cdc5
  • Loading branch information
davidtaylorhq committed Aug 14, 2019
1 parent 92f2202 commit 5755d38
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/auth/result.rb
Expand Up @@ -19,7 +19,7 @@ def initialize
end

def email
@email.downcase
@email&.downcase
end

def failed?
Expand Down
11 changes: 11 additions & 0 deletions spec/components/auth/managed_authenticator_spec.rb
Expand Up @@ -140,6 +140,17 @@ def match_by_email
result = authenticator.after_authenticate(hash)
expect(result.user.id).to eq(user.id)
end

it 'works if there is no email' do
expect {
result = authenticator.after_authenticate(hash.deep_merge(info: { email: nil }))
expect(result.user).to eq(nil)
expect(result.username).to eq("IAmGroot")
expect(result.email).to eq(nil)
}.to change { UserAssociatedAccount.count }.by(1)
expect(UserAssociatedAccount.last.user).to eq(nil)
expect(UserAssociatedAccount.last.info["nickname"]).to eq("IAmGroot")
end
end

describe "avatar on update" do
Expand Down

0 comments on commit 5755d38

Please sign in to comment.