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

Fix fetch auth handling on non-default remote

This commit is contained in:
Nick O'Leary 2018-02-02 16:26:55 +00:00
parent d21568497b
commit fc1436a96d
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 12 additions and 11 deletions

View File

@ -691,15 +691,15 @@ RED.projects = (function() {
} else { } else {
projectRepoInput.removeClass("input-error"); projectRepoInput.removeClass("input-error");
} }
if (/^(?:ssh|[\S]+?@[\S]+?):(?:\/\/)?/.test(repo)) { if (/^https?:\/\//.test(repo)) {
$(".projects-dialog-screen-create-row-creds").show();
$(".projects-dialog-screen-create-row-sshkey").hide();
} else if (/^(?:ssh|[\S]+?@[\S]+?):(?:\/\/)?/.test(repo)) {
$(".projects-dialog-screen-create-row-creds").hide(); $(".projects-dialog-screen-create-row-creds").hide();
$(".projects-dialog-screen-create-row-sshkey").show(); $(".projects-dialog-screen-create-row-sshkey").show();
// if ( !getSelectedSSHKey(projectRepoSSHKeySelect) ) { // if ( !getSelectedSSHKey(projectRepoSSHKeySelect) ) {
// valid = false; // valid = false;
// } // }
} else if (/^https?:\/\//.test(repo)) {
$(".projects-dialog-screen-create-row-creds").show();
$(".projects-dialog-screen-create-row-sshkey").hide();
} else { } else {
$(".projects-dialog-screen-create-row-creds").hide(); $(".projects-dialog-screen-create-row-creds").hide();
$(".projects-dialog-screen-create-row-sshkey").hide(); $(".projects-dialog-screen-create-row-sshkey").hide();
@ -1509,7 +1509,7 @@ RED.projects = (function() {
resultCallbackArgs = {error:responses.statusText}; resultCallbackArgs = {error:responses.statusText};
return; return;
} else if (options.handleAuthFail !== false && xhr.responseJSON.error === 'git_auth_failed') { } else if (options.handleAuthFail !== false && xhr.responseJSON.error === 'git_auth_failed') {
var url = activeProject.git.remotes[options.remote||'origin'].fetch; var url = activeProject.git.remotes[xhr.responseJSON.remote||options.remote||'origin'].fetch;
var message = $('<div>'+ var message = $('<div>'+
'<div class="form-row">Authentication required for repository:</div>'+ '<div class="form-row">Authentication required for repository:</div>'+
@ -1517,7 +1517,10 @@ RED.projects = (function() {
'</div>'); '</div>');
var isSSH = false; var isSSH = false;
if (/^(?:ssh|[\d\w\.\-_]+@[\w\.]+):(?:\/\/)?/.test(url)) { if (/^https?:\/\//) {
$('<div class="form-row"><label for="projects-user-auth-username">Username</label><input id="projects-user-auth-username" type="text"></input></div>'+
'<div class="form-row"><label for=projects-user-auth-password">Password</label><input id="projects-user-auth-password" type="password"></input></div>').appendTo(message);
} else if (/^(?:ssh|[\d\w\.\-_]+@[\w\.]+):(?:\/\/)?/.test(url)) {
isSSH = true; isSSH = true;
var row = $('<div class="form-row"></div>').appendTo(message); var row = $('<div class="form-row"></div>').appendTo(message);
$('<label for="projects-user-auth-key">SSH Key</label>').appendTo(row); $('<label for="projects-user-auth-key">SSH Key</label>').appendTo(row);
@ -1535,9 +1538,6 @@ RED.projects = (function() {
row = $('<div class="form-row"></div>').appendTo(message); row = $('<div class="form-row"></div>').appendTo(message);
$('<label for="projects-user-auth-passphrase">Passphrase</label>').appendTo(row); $('<label for="projects-user-auth-passphrase">Passphrase</label>').appendTo(row);
$('<input id="projects-user-auth-passphrase" type="password"></input>').appendTo(row); $('<input id="projects-user-auth-passphrase" type="password"></input>').appendTo(row);
} else {
$('<div class="form-row"><label for="projects-user-auth-username">Username</label><input id="projects-user-auth-username" type="text"></input></div>'+
'<div class="form-row"><label for=projects-user-auth-password">Password</label><input id="projects-user-auth-password" type="password"></input></div>').appendTo(message);
} }
var notification = RED.notify(message,{ var notification = RED.notify(message,{
@ -1575,7 +1575,7 @@ RED.projects = (function() {
} }
sendRequest({ sendRequest({
url: "projects/"+activeProject.name+"/remotes/"+(options.remote||'origin'), url: "projects/"+activeProject.name+"/remotes/"+(xhr.responseJSON.remote||options.remote||'origin'),
type: "PUT", type: "PUT",
responses: { responses: {
0: function(error) { 0: function(error) {

View File

@ -438,8 +438,9 @@ module.exports = {
res.json(data); res.json(data);
}) })
.catch(function(err) { .catch(function(err) {
console.log(err);
if (err.code) { if (err.code) {
res.status(400).json({error:err.code, message: err.message}); res.status(400).json({error:err.code, message: err.message, remote: err.remote});
} else { } else {
res.status(400).json({error:"unexpected_error", message:err.toString()}); res.status(400).json({error:"unexpected_error", message:err.toString()});
} }