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

Clear HTTP Request node authType when auth disabled

Fixes #2215
This commit is contained in:
Nick O'Leary 2019-06-20 22:33:38 +01:00
parent e315325d91
commit 46abd0cc42
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -49,12 +49,13 @@
<label for="node-input-useAuth" style="width: 70%;"><span data-i18n="httpin.basicauth"></span></label> <label for="node-input-useAuth" style="width: 70%;"><span data-i18n="httpin.basicauth"></span></label>
<div style="margin-left: 20px" class="node-input-useAuth-row hide"> <div style="margin-left: 20px" class="node-input-useAuth-row hide">
<div class="form-row"> <div class="form-row">
<label for="node-input-authType"><i class="fa fa-user-secret "></i> <span data-i18n="httpin.label.authType"></span></label> <label for="node-input-authType-select"><i class="fa fa-user-secret "></i> <span data-i18n="httpin.label.authType"></span></label>
<select type="text" id="node-input-authType" style="width:70%;"> <select type="text" id="node-input-authType-select" style="width:70%;">
<option value="basic" data-i18n="httpin.basic"></option> <option value="basic" data-i18n="httpin.basic"></option>
<option value="digest" data-i18n="httpin.digest"></option> <option value="digest" data-i18n="httpin.digest"></option>
<option value="bearer" data-i18n="httpin.bearer"></option> <option value="bearer" data-i18n="httpin.bearer"></option>
</select> </select>
<input type="hidden" id="node-input-authType">
</div> </div>
<div class="form-row node-input-basic-row"> <div class="form-row node-input-basic-row">
<label for="node-input-user"><i class="fa fa-user"></i> <span data-i18n="common.label.username"></span></label> <label for="node-input-user"><i class="fa fa-user"></i> <span data-i18n="common.label.username"></span></label>
@ -102,7 +103,7 @@
url:{value:"",validate:function(v) { return (v.trim().length === 0) || (v.indexOf("://") === -1) || (v.trim().indexOf("http") === 0)} }, url:{value:"",validate:function(v) { return (v.trim().length === 0) || (v.indexOf("://") === -1) || (v.trim().indexOf("http") === 0)} },
tls: {type:"tls-config",required: false}, tls: {type:"tls-config",required: false},
proxy: {type:"http proxy",required: false}, proxy: {type:"http proxy",required: false},
authType: {value: "basic"} authType: {value: ""}
}, },
credentials: { credentials: {
user: {type:"text"}, user: {type:"text"},
@ -130,7 +131,7 @@
$(".node-input-useAuth-row").show(); $(".node-input-useAuth-row").show();
// Nodes (< version 0.20.x) with credentials but without authentication type, need type 'basic' // Nodes (< version 0.20.x) with credentials but without authentication type, need type 'basic'
if (!$('#node-input-authType').val()) { if (!$('#node-input-authType').val()) {
$('#node-input-authType').val('basic'); $("#node-input-authType-select").val('basic').trigger("change");
} }
} else { } else {
$(".node-input-useAuth-row").hide(); $(".node-input-useAuth-row").hide();
@ -139,12 +140,14 @@
$('#node-input-password').val(''); $('#node-input-password').val('');
} }
}); });
$("#node-input-authType").change(function() { $("#node-input-authType-select").change(function() {
if ($(this).val() == "basic" || $(this).val() == "digest") { var val = $(this).val();
$("#node-input-authType").val(val);
if (val === "basic" || val === "digest") {
$(".node-input-basic-row").show(); $(".node-input-basic-row").show();
$('#node-span-password').show(); $('#node-span-password').show();
$('#node-span-token').hide(); $('#node-span-token').hide();
} else if ($(this).val() == "bearer") { } else if (val === "bearer") {
$(".node-input-basic-row").hide(); $(".node-input-basic-row").hide();
$('#node-span-password').hide(); $('#node-span-password').hide();
$('#node-span-token').show(); $('#node-span-token').show();
@ -158,8 +161,9 @@
$(".node-input-paytoqs-row").hide(); $(".node-input-paytoqs-row").hide();
} }
}); });
if (this.credentials.user || this.credentials.has_password) { if (this.authType) {
$('#node-input-useAuth').prop('checked', true); $('#node-input-useAuth').prop('checked', true);
$("#node-input-authType-select").val(this.authType);
} else { } else {
$('#node-input-useAuth').prop('checked', false); $('#node-input-useAuth').prop('checked', false);
} }