Refactor login.js:

- Take Connection event handlers out of $scope functions
- Add setError function that takes care of $rootScope.$apply