fixed logout error due to missing sid

This commit is contained in:
Ritchie Martori
2012-03-29 08:36:25 -07:00
parent a4384d3d30
commit a5a24db61c
2 changed files with 6 additions and 1 deletions

View File

@@ -32,6 +32,11 @@ module.exports = function (req, res, next) {
// skip without a resource
if(!resource) return next({error: 'Could not find a resource to validate.', status: 404});
// default _id to current user when logging out
if(resource.type === 'UserCollection' && req.url.indexOf('/logout') === req.url.lastIndexOf('/')) {
req.query._id = req.session._id;
}
// if modifying data, require an id
if((req.method === 'PUT' || req.method === 'DELETE') && (!req.query || !req.query._id)) {
return next({error: 'An _id must be included when modifying a resource.'});

View File

@@ -53,7 +53,7 @@ describe('Users', function(){
// TODO fix mdoq-http bug - loses context if replace client with users
users.use('/login').post({email: data.users[0].email, password: data.users[0].password}, function (err, session, req, res) {
// SHOULD BE USERS
client.use('/users/logout').del(function (err, res) {
unauthed.use('/users/logout').del(function (err, res) {
done(err);
});
})