bnoguchi/mongoose-auth

findOrCreateUser not returning a promise if the server restarted

Closed this issue · 5 comments

Try the following using any of the strategies and using mongoose-auth:

  1. Start your server. Works.
  2. Authenticate using one of the methods facebook, github or twitter. Works.
  3. User saved to users collection. Session is saved to sessions. Works.
  4. Kill the server using Ctrl-C while leaving the browser as-is. Works.
  5. Start the server again. Works.
  6. Refresh your browser, your session is gone. I see your comment in lib/modules/facebook/everyauth.js, you have // TODO Check user in session or request helper first. The session is gone is fine.
  7. Try to login using facebook or any other method. Does not Work. Result: Error: Step findOrCreateUser of facebook module timed out.

Is it possible to give a hint if you don't have time to fix it, may be clear the sessions in the db? not sure where the issue is coming from

Are you trying to reload the user and assign the req.user object on when the app starts back up? Here's a full working example, I published a bit ago: https://github.com/brandonhall/node-social-auth-boilerplate - it works with Google & Facebook with persistence

Your example worked fine. So it must be something i was doing wrong. I'll come back with explanation.

I tried your example and dependencies fail because you have spaces in the app name and missing restler, mkdirp, bcrypt, mongodb, oauth, mongoose-types dependencies in the package.

And thank you!

Sure thing, happy to share. I didn't run into those issues when running the app. Guess I just need to update the README that's it more copy/paste than a true boilerplate

Actually the example in the mongoose-auth works well for me. The issue that I was having was caused by the fact that I had a method which takes care of initializing the userSchema but called it twice instead of once which produce strange behavior.