1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

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
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
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 {

View File

@ -706,7 +706,9 @@ Project.prototype.fetch = function(user,remoteName) {
promise = promise.then(function() {
return gitTools.fetch(project.path,remote,authCache.get(project.name,project.remotes[remote].fetch,username))
}).catch(function(err) {
err.remote = remote;
if (!err.remote) {
err.remote = remote;
}
throw err;
})
});