Simplified code. Removed LoginCtrl. Put most of the functionality into the LoginBox directive, which is where it belongs.