Have user avatar endpoint check that id is valid

To limit errors for client tests which send invalid ids
This commit is contained in:
Scott Erickson 2016-03-17 13:09:00 -07:00
parent 461fb14f37
commit 61953219a4

View file

@ -506,6 +506,8 @@ UserHandler = class UserHandler extends Handler
hipchat.sendHipChatMessage "#{req.body.githubUsername or req.user.get('name')} just signed the CLA.", ['main']
avatar: (req, res, id) ->
if not isID(id)
return @sendBadInputError(res, 'Invalid avatar id')
@modelClass.findById(id).exec (err, document) =>
return @sendDatabaseError(res, err) if err
return @sendNotFoundError(res) unless document