colinskow / ng-superlogin

AngularJS bindings for the SuperLogin project
MIT License
15 stars 17 forks source link

401 for superlogin.logout() #15

Open Kluskey opened 8 years ago

Kluskey commented 8 years ago

Hi there,

Thanks for working on this repository - It really is a huge timesaver.

I'm not sure if there's a bug or if I'm doing this incorrectly, but when I call superlogin.logout() I get a 401 error that says "unauthorized".

Before the function call, I can successfully get a logged-in response from superlogin.getSession(). After the function call, if I call superlogin.getSession() again, I get "null" - so the user is actually getting logged out.

As well, if I call superlogin.logoutAll(), everything works fine without any errors.

Any thoughts?

Thanks for your help!

Info: Running nodeJS express superlogin server backend with Cloudant for CouchDB, and Angular Cordova app on the front-end.

ichagas commented 8 years ago

@Kluskey I had the same issue and solved adding Authorization in the Access-Control-Allow-Headers in the Node Server Express.

Here is the code I added in my server side:

app.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
  next();
});

I hope this help you.

colinskow commented 8 years ago

The other possibility is that the user's access token has already expired.