I am calling
Meteor.logout() in an Angular-Meteor (v4.1/v1.4) project. The method executes correctly and invokes my callback function when the server is reachable, but neither invokes the callback function nor resets
Meteor.userId() when the server is unreachable, leaving the current user logged in for all practical purposes.
I am calling
When offline you can do it like
Meteor._localStorage.removeItem('Meteor.loginToken'); Meteor._localStorage.removeItem('Meteor.loginTokenExpires'); Meteor._localStorage.removeItem('Meteor.userId');
Thanks, @mrzafod. The
_localStorage property does not seem to be included in the TypeScript definitions for Meteor, so I get
Property '_localStorage' does not exist on type 'typeof Meteor'. when I attempt this solution.
Make shure your code is on the client side and
accounts-base package included. You can try to type
Meteor._localStorage into browser console to check it out. Anyway
Meteor._localStorage is just a wrapper for
window.localStorage, so you could type it like
window.localStorage.removeItem('Meteor.loginToken'); window.localStorage.removeItem('Meteor.loginTokenExpires'); window.localStorage.removeItem('Meteor.userId');
You can use
Accounts.makeClientLoggedOut to do this. See:
Thanks, @mrzafod. Those conditions are true in my project and I can call
Meteor._localStorage methods from the browser console. As I said in my first reply, the issue is that the
_localStorage property is not declared in the Meteor TypeScript definitions, which is problematic for Angular projects, which are commonly written in TypeScript. The same is true for the
Accounts.function makeClientLoggedOut method identified by @hwillson, but which I have successfully implemented in my project.
I’ll take up the missing TypeScript definitions as a Github Issue.
Thanks to you both for your help solving this!