mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
Update all nodes to credentials system and auth middleware
This commit is contained in:
@@ -42,44 +42,12 @@
|
||||
port: { value: 5432,required:true},
|
||||
db: { value:"postgres",required:true}
|
||||
},
|
||||
credentials: {
|
||||
user: {type:"text"},
|
||||
password: {type: "password"}
|
||||
},
|
||||
label: function() {
|
||||
return this.name||this.hostname+":"+this.port+"/"+this.db;
|
||||
},
|
||||
oneditprepare: function() {
|
||||
|
||||
$.getJSON('postgresdb/'+this.id,function(data) {
|
||||
if (data.user) {
|
||||
$('#node-config-input-user').val(data.user);
|
||||
}
|
||||
if (data.hasPassword) {
|
||||
$('#node-config-input-password').val('__PWRD__');
|
||||
} else {
|
||||
$('#node-config-input-password').val('');
|
||||
}
|
||||
});
|
||||
},
|
||||
oneditsave: function() {
|
||||
|
||||
var newUser = $('#node-config-input-user').val();
|
||||
var newPass = $('#node-config-input-password').val();
|
||||
var credentials = {};
|
||||
credentials.user = newUser;
|
||||
if (newPass != '__PWRD__') {
|
||||
credentials.password = newPass;
|
||||
}
|
||||
$.ajax({
|
||||
url: 'postgresdb/'+this.id,
|
||||
type: 'POST',
|
||||
data: credentials,
|
||||
success:function(result){}
|
||||
});
|
||||
},
|
||||
ondelete: function() {
|
||||
$.ajax({
|
||||
url: 'postgresdb/'+this.id,
|
||||
type: 'DELETE',
|
||||
success: function(result) {}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user