Skip to content

Commit

Permalink
Merge pull request #606 from chef/dp_nil_username_ocid
Browse files Browse the repository at this point in the history
nil username breaks Analytics login
  • Loading branch information
bookshelfdave committed Nov 4, 2015
2 parents f2ad735 + ae8b9ec commit fa1f66f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/oc-id/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def admin?(username)

def find(username)
begin
if (username.include?('@'))
if (username != nil && username.include?('@'))
users = self.new.chef.get(
"users?#{{ email: username }.to_query}"
)
Expand Down
4 changes: 4 additions & 0 deletions src/oc-id/spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
expect(User.find(jimmy.email)).to eql(jimmy)
end

it 'doesnt blow up when user is nil' do
expect(User.find(nil)).to be_nil
end

describe 'updating a password' do
fields = [:current_password, :new_password, :password_confirmation]
fields.each do |f|
Expand Down

0 comments on commit fa1f66f

Please sign in to comment.