-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging out #20
Comments
Managed to do a full logout by triggering $window.location.reload() which stopped any further posting without re-logging in as well as getting rid of currentUser. This seems to do the job for now but if you know any problems that this solution could bring up, please do let me know! many thanks. |
I could be wrong but this is how I did it. I added a logout function to the User Service to clear the request header: svc.logout = function() {
$http.defaults.headers.common['X-Auth'] = undefined;
} Then I added logout to the Application Controller to clear the current user variable and call the new service function: $scope.logout = function() {
$scope.currentUser = undefined;
UserSvc.logout();
} |
Thanks NemSavic, I had exactly same but had $http.defaults.headers.common['X-Auth'] = null; I had 'null' instead of 'undefined' and it gave me http code for 500 for every controller call. Switching it to be undefined solves the issue. |
Just in case anyone else is looking at this in the future, you should not set the header to undefined or null. Instead use |
Hi Dickey, I am trying to remove JWT from request so that one can logout even though there is no session. May I ask where does JWT is kept at the moment? I tried saving it to $window.sessionStorage.token or localStorage so that I can delete it when logout is clicked. However, the program does not like the '$' sign in front of window. Any clue you can give as to how I can remove JWT from request and where it is kept once logged in? Brower's memory? cookies? So many thanks.
The text was updated successfully, but these errors were encountered: