emit an "error" event when an error happens on the /auth endpoint

See #1.
add TODO item