mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add better handling of host-key-verify error with projects
This commit is contained in:
parent
09d55a0cbd
commit
20f97d0d13
@ -977,7 +977,8 @@
|
|||||||
"passphrase": "Passphrase",
|
"passphrase": "Passphrase",
|
||||||
"retry": "Retry",
|
"retry": "Retry",
|
||||||
"update-failed": "Failed to update auth",
|
"update-failed": "Failed to update auth",
|
||||||
"unhandled": "Unhandled error response"
|
"unhandled": "Unhandled error response",
|
||||||
|
"host-key-verify-failed": "<p>Host key verification failed.</p><p>The repository host key could not be verified. Please update your <code>known_hosts</code> file and try again."
|
||||||
},
|
},
|
||||||
"create-branch-list": {
|
"create-branch-list": {
|
||||||
"invalid": "Invalid branch",
|
"invalid": "Invalid branch",
|
||||||
|
@ -1939,13 +1939,15 @@ RED.projects = (function() {
|
|||||||
}
|
}
|
||||||
}).fail(function(xhr,textStatus,err) {
|
}).fail(function(xhr,textStatus,err) {
|
||||||
var responses;
|
var responses;
|
||||||
|
|
||||||
if (options.responses && options.responses[xhr.status]) {
|
if (options.responses && options.responses[xhr.status]) {
|
||||||
responses = options.responses[xhr.status];
|
responses = options.responses[xhr.status];
|
||||||
if (typeof responses === 'function') {
|
if (typeof responses === 'function') {
|
||||||
resultCallback = responses;
|
resultCallback = responses;
|
||||||
resultCallbackArgs = {error:responses.statusText};
|
resultCallbackArgs = {error:responses.statusText};
|
||||||
return;
|
return;
|
||||||
} else if (options.handleAuthFail !== false && xhr.responseJSON.code === 'git_auth_failed') {
|
} else if (options.handleAuthFail !== false && (xhr.responseJSON.code === 'git_auth_failed' || xhr.responseJSON.code === 'git_host_key_verification_failed')) {
|
||||||
|
if (xhr.responseJSON.code === 'git_auth_failed') {
|
||||||
var url = activeProject.git.remotes[xhr.responseJSON.remote||options.remote||'origin'].fetch;
|
var url = activeProject.git.remotes[xhr.responseJSON.remote||options.remote||'origin'].fetch;
|
||||||
|
|
||||||
var message = $('<div>'+
|
var message = $('<div>'+
|
||||||
@ -2033,6 +2035,25 @@ RED.projects = (function() {
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
} else if (xhr.responseJSON.code === 'git_host_key_verification_failed') {
|
||||||
|
var message = $('<div>'+
|
||||||
|
'<div class="form-row">'+RED._("projects.send-req.host-key-verify-failed")+'</div>'+
|
||||||
|
'</div>');
|
||||||
|
var notification = RED.notify(message,{
|
||||||
|
type:"error",
|
||||||
|
fixed: true,
|
||||||
|
modal: true,
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
text: RED._("common.label.close"),
|
||||||
|
click: function() {
|
||||||
|
notification.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else if (responses[xhr.responseJSON.code]) {
|
} else if (responses[xhr.responseJSON.code]) {
|
||||||
resultCallback = responses[xhr.responseJSON.code];
|
resultCallback = responses[xhr.responseJSON.code];
|
||||||
resultCallbackArgs = xhr.responseJSON;
|
resultCallbackArgs = xhr.responseJSON;
|
||||||
|
@ -41,6 +41,9 @@ function runGitCommand(args,cwd,env,emit) {
|
|||||||
err.code = "git_connection_failed";
|
err.code = "git_connection_failed";
|
||||||
} else if (/Connection timed out/i.test(stderr)) {
|
} else if (/Connection timed out/i.test(stderr)) {
|
||||||
err.code = "git_connection_failed";
|
err.code = "git_connection_failed";
|
||||||
|
} else if(/Host key verification failed/i.test(stderr)) {
|
||||||
|
// TODO: handle host key verification errors separately
|
||||||
|
err.code = "git_host_key_verification_failed";
|
||||||
} else if (/fatal: could not read/i.test(stderr)) {
|
} else if (/fatal: could not read/i.test(stderr)) {
|
||||||
// Username/Password
|
// Username/Password
|
||||||
err.code = "git_auth_failed";
|
err.code = "git_auth_failed";
|
||||||
@ -48,9 +51,6 @@ function runGitCommand(args,cwd,env,emit) {
|
|||||||
err.code = "git_auth_failed";
|
err.code = "git_auth_failed";
|
||||||
} else if(/Permission denied \(publickey\)/i.test(stderr)) {
|
} else if(/Permission denied \(publickey\)/i.test(stderr)) {
|
||||||
err.code = "git_auth_failed";
|
err.code = "git_auth_failed";
|
||||||
} else if(/Host key verification failed/i.test(stderr)) {
|
|
||||||
// TODO: handle host key verification errors separately
|
|
||||||
err.code = "git_auth_failed";
|
|
||||||
} else if (/commit your changes or stash/i.test(stderr)) {
|
} else if (/commit your changes or stash/i.test(stderr)) {
|
||||||
err.code = "git_local_overwrite";
|
err.code = "git_local_overwrite";
|
||||||
} else if (/CONFLICT/.test(err.stdout)) {
|
} else if (/CONFLICT/.test(err.stdout)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user