Skip to content

Instantly share code, notes, and snippets.

@dmcassel
Created May 31, 2014 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmcassel/fe913e5e422bf5730f0a to your computer and use it in GitHub Desktop.
Save dmcassel/fe913e5e422bf5730f0a to your computer and use it in GitHub Desktop.
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