tphummel/node-waze — pull request #2 by jmealo (2014-04-29 01:52:42+00:00)
Title: Fix for Issue #1: Login error handling

Kudos on writing this module, I was bummed to find that it stopped working. Rather than writing my own, I decided to fix #1.

This pull requests fixes an issue with new security measures put in place by Waze. Waze now returns a 405 Error when the `X-CSRF-Token` HTTP header is not set when calling `/login/create`

Additionally, it adds error handling to the login function by passing connection errors and errors sent by the Waze server.

**This does not pass one of the included unit tests because of the way the replay modifies the `err` value returned by request.**

I did not update the unit tests as they do not account for connection errors, authentication errors or JSON parsing errors.

I'm somewhat confused by the pattern of wrapping each module in a closure as require does this automatically (which is why one must use module.exports).