Sunday 19 March 2017

Broadcasting Logout

Someone posted something very similar to the following code on a thread about resources that I can no longer locate:

$scope.logout = function(){ 
    var outRes = $resource("/admin/logout"); 
    outRes.save({}, 
    function () { 
        $scope.userObject.lastActivity_type = "Log out"; 
        $rootScope.isLoggedIn = false; 
        $location.path("/login-register"); 
    }, 
    function errorHandling(err) {
        console.log("Not cool, error"); 
    }); 
}

It was super helpful for me on my assignment and seemed fairly recent so I was hoping to ask: could someone explain how to rewrite this with a broadcast method to let other users/every part of architecture know a user has logged out? The assignment's over and everything, I'm just curious



via Sona Allahverdi

No comments:

Post a Comment