1

I am unable to clear access token event after logging out. I just created method which is clearing whole user object and redirecting to login page when clicking on logout button.

$scope.logout = function(){

    $scope.user ={};
    $state.go('static.login');
    $(".loader").fadeOut("slow");

}

Still I able to see access token in Application tab while inspecting login page.

enter image description here

Above is image that can show, And I able to see last logged in user object details while debugging after clicking submit without entering any credentials.As you can see below.

enter image description here

$scope.setCookie = function(cname, cvalue, exMins) {
    var d = new Date();
    d.setTime(d.getTime() + (exMins*60*1000));
    var expires = "expires="+d.toUTCString();  
    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

after modification of logout method. clearing access token.

$scope.logout = function(){

    /*
    $state.go('static.login');
    $(".loader").fadeOut("slow");*/
      //var token=$cookies.get('ACCESS_TOKEN');
      $cookies.remove('ACCESS_TOKEN');
      $scope.user={};
      $state.go('static.login');

}
phani kumar
  • 117
  • 10

1 Answers1

0

Check this example for your problem

Sample

//remove token
$cookies.remove('token');
Parshwa Shah
  • 331
  • 4
  • 14
  • I able to clear access token But, I am unable to clear last logged in user object. You can see in question how I did. – phani kumar Mar 13 '19 at 08:06
  • yes, after log out I checked user object in debugging by clicking login without entering any credentials then too object consists user details. – phani kumar Mar 13 '19 at 09:03
  • During login you are storing data in $rootScope as per your screenshot so change logout code and write `$rootScope.user = {}` – Parshwa Shah Mar 13 '19 at 12:52