Can't get custom logout to work?


hI have a meteor.js application where I am doing some custom authentication. I would like to implement a logout that would end the current session. I tried to create a route like the one below and a anchor that directed to that URL:

FlowRouter.route '/logoutUser',
  action: (params) ->
    console.log "start logout"
    Meteor.logout (err) ->
      console.log err if err
      console.log "after logout"
      FlowRouter.go 'login'
      console.log "after after"

When users clicked the link and navigated to /logoutUser, it would change the URL in the nav bar to /logoutUser, the console would log start logout, but the user would not be logged out and the callback would never be called. If I manually hit the /logoutUser url it successfully logs the user out and reaches the callback. I’ve also noticed that if I go into the console and type Meteor.logout() it still doesn’t appear to be logging the current user out.

Does anyone know why this would be happening? Any idea on how I can successfully log the user out using this method?


Just a side note, generally triggering a logout should be done via a button or user event - not a URL.
Reasoning is that someone might be redirected to that link from an email, IM, a link shortener or any other methods. At least with meteor it wouldn’t work with an <img> tag unless you also had server side routing…

I am not sure about your code, I don’t quite follow the flow of the coffee script.
It should work.

Perhaps the issue is that your user is being logged out. However part of your UI is not reactive to that change?

If you navigate to the logout page, triggering the logout event, and open another tab to a normal page, are you still logged in??