Added scope.apply on login and logout