Ensure auth failure on project fetch identifies the remote

Fixes #2545
This commit is contained in:
Nick O'Leary
2020-05-21 17:18:46 +01:00
parent 89a048e5fa
commit 8ce49c25d4
2 changed files with 11 additions and 3 deletions

View File

@@ -43,10 +43,16 @@ module.exports = {
rejectHandler: function(req,res,err) {
//TODO: why this when errorHandler also?!
log.audit({event: "api.error",error:err.code||"unexpected_error",message:err.message||err.toString()},req);
res.status(err.status||400).json({
var response = {
code: err.code||"unexpected_error",
message: err.message||err.toString()
});
};
// Handle auth failures on a specific remote
// TODO: don't hardcode this here - allow users of rejectHandler to identify extra props to send
if (err.remote) {
response.remote = err.remote;
}
res.status(err.status||400).json(response);
},
getRequestLogObject: function(req) {
return {