2

I am currently using node.js, express, and mongodb for an instagram app. I have found that many times I would like to know whether or not a user is already logged into instagram (be it through my app via the instagram-node authentication or through instagram's actual website).

Is there an easy way to do this?

Blakes Seven
  • 49,422
  • 14
  • 129
  • 135
prcbass
  • 339
  • 1
  • 3
  • 17
  • Please let me know if any additional information would help in answering this question – prcbass Jul 02 '15 at 07:02
  • "through my app via the instagram-node authentication or through instagram's actual website" It's not the same – michelem Jul 02 '15 at 09:22
  • I would like to know once a user has logged in through the Instagram api which is in my app. Does that clarify the question? – prcbass Jul 02 '15 at 16:36
  • It bothers me that someone would bother commenting on an unanswered question only to criticize. At least provide some input. Either way, I was able to find another question that is along the same lines of what I had in mind: http://stackoverflow.com/questions/26378345/switch-user-or-re-authenticate-with-instagram – prcbass Jul 02 '15 at 23:45
  • I simply cannot understand your needs and you didn't post any code. How can I help you? I don't know. – michelem Jul 03 '15 at 06:58

1 Answers1

1

I ended up using passport to solve this problem. Passport conveniently takes care of handling instagram authorization and they even include an example app to see how it all works. https://github.com/jaredhanson/passport-instagram/blob/master/examples/login/app.js

function ensureAuthenticated(req, res, next) {
  if (req.isAuthenticated()) { return next(); }
  res.redirect('/login')
}

Is especially useful since it can be placed at the top of your routing file and all the routes underneath it will first check to see if the user is authenticated.

prcbass
  • 339
  • 1
  • 3
  • 17