sishen/omniauth-bitbucket — pull request #5 by liubin0329 (2013-07-18 10:00:23+00:00)
Title: bugfix: crash when no confirmed email

Hi sishen

I found that when link to bitbucket account without any email confirmed, it's will crash with errors:

A NoMethodError occurred in #:
undefined method `[]' for nil:NilClass
omniauth-bitbucket (0.0.1) lib/omniauth/strategies/bitbucket.rb:33:in `raw_info'

The root cause is that at this case Bitbucket API will not give us emails with primary as true.

the result of emails API is:

without email confirmed:

"email"=>
[{"active": false, "email": "bin@liubin.org", "primary": false}]"}]

with email confirmed:

"email"=>
[{"active": true, "email": "liubin0329@gmail.com", "primary": true}]"}]

Above all ,I think my code can fix this issue and will return nil when no valid email is provided.

BR.