Allow user details only for the same user or admins

This commit is contained in:
Johannes Zellner
2016-02-25 13:44:53 +01:00
parent b5b0ab7475
commit 4f7fd9177c

View File

@@ -136,6 +136,8 @@ function listUser(req, res, next) {
function info(req, res, next) {
assert.strictEqual(typeof req.params.userId, 'string');
if (req.user.id !== req.params.userId && !req.user.admin) return next(new HttpError(403, 'Not allowed'));
user.get(req.params.userId, function (error, result) {
if (error && error.reason === UserError.NOT_FOUND) return next(new HttpError(404, 'No such user'));
if (error) return next(new HttpError(500, error));