Refactor/restructure login.js:

- Take Connection event handlers out of $scope functions
- Add setError function that takes care of $rootScope.$apply
- Get rid of `connecting` and `connected` variables in LoginCtrl and instead put them in the Connection API