2015년 3월 10일 화요일

node passport session recreate error

node passport session recreate error

when client(ex ios) send 2 request as parallels
1 request is logout
2 request is unregist push notification
2 requests have user logined cookie
so when that requests arrive at node server
passport always do upsert at user session
but if requests processed as below sequence it can make recreate session error

  1. logout request do upsert by passport because request has user session info
    and it returned
  2. logout
    remove session sended at DB
    and it queueed at node asycle cycle
  3. DB delete user session
  4. unregist push notification request do upsert by passport because request has user session info
    DB recreate user session
  5. logout response returned with success
  6. unregist push notification response returned with success
both request success in client
so client think logout success
but in db user session recreated with login status