express-stormpath
express-stormpath copied to clipboard
Cannot GET /login or /logout
I've set up a simple express app with stormpath. I am able to get the /register
route and am able to create account however I cannot get either the /login
or /logout
routes after registering an account. My index.js is as below. I suppose the reason I can't get the login route is because my session is still active. The documentation says the library by default provides a logout
handler throught the /logout
route. However hitting this route when I am logged in doesn't work.
var express = require('express');
var stormpath = require('express-stormpath');
var app = express();
app.use(stormpath.init(app,{
application:{
href: 'https://api.stormpath.com/v1/applications/XXXXXXXXXXXXXXXXXX'
},
website:true
}));
app.get('/',stormpath.loginRequired,function(req,res){
res.send('Hi'+ req.user.givenName);
});
app.on('stormpath.ready',function(){
console.log('starting server on port 3000');
app.listen(3000);
});
My package.json as below
{
"name": "storm",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Fitz",
"license": "ISC",
"dependencies": {
"express": "^4.14.0",
"express-stormpath": "^3.1.3"
}
}
Hi @anesumuz , thanks for the information. What kind of error do you get when trying to request the /login
route?
Please not that the website: true
option is no loner necessary, and you don't have to wait for stormpath.ready
either. We made this changes in the first 3.x version and you can read about them in the changelog here:
http://docs.stormpath.com/nodejs/express/latest/changelog.html#major-release-3-0-0
@anesumuz I recently upgraded to 3.1.3 as well. I noticed that the /logout route now requires a POST rather than a GET, which was not the case in 2.x (at least the prior version I had). I'm assuming there were similar changes to /login
I am still having the same issue using Stompath and Heroku, the logout route is not added. Is there a work around this ?. How could i make the route /logout actually work ?
Hi @tuytuy , can you confirm that you are making a POST request to the /logout
url? GET will not work. Thanks!