Created
May 31, 2014 02:15
-
-
Save dmcassel/fe913e5e422bf5730f0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.put('/v1*', function(req, res){ | |
if (req.session.user === undefined) { | |
res.send(401, 'Unauthorized'); | |
} else if (req.path === '/v1/documents' && | |
req.query.uri.match('/users/') && | |
req.query.uri.match(new RegExp('/users/[^(' + req.session.user.name + ')]+.json'))) { | |
// The user is try to PUT to a profile document other than his/her own. Not allowed. | |
res.send(403, 'Forbidden'); | |
} else { | |
if (req.path === '/v1/documents' && req.query.uri.match('/users/')) { | |
// TODO: The user is updating the profile. Update the session info. | |
} | |
proxy(req, res); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment