Code Refactoring: Using promises for authentication. use (abuse) of $rootScope is removed.