Skip to content

Commit

Permalink
Remove username/password fields
Browse files Browse the repository at this point in the history
  • Loading branch information
chughts committed Mar 24, 2022
1 parent a49bcd5 commit f6fe6d0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 41 deletions.
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@ Node-RED Watson Nodes for IBM Cloud
- Min version of Node is 12.20.0
- Drop Personality Insights node
- Drop Visual Recognition nodes
- Remove Username / Password fields from nodes for
- Assistant V1
- Assistant V2
- Discovery V1
- Language Translator nodes
- Natural Language Classifier
- Speech to Text
- Text to Speech
- Remove Username / Password fields from all nodes


### Watson Nodes for Node-RED
Expand Down
13 changes: 2 additions & 11 deletions services/tone_analyzer/v3.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright 2013,2015 IBM Corp.
Copyright 2013,2022 IBM Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -24,14 +24,7 @@
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row credentials" style="display: none;">
<label for="node-input-username"><i class="fa fa-user"></i> Username</label>
<input type="text" id="node-input-username" placeholder="Username">
</div>
<div class="form-row credentials" style="display: none;">
<label for="node-input-password"><i class="fa fa-key"></i> Password</label>
<input type="password" id="node-input-password" placeholder="Password">
</div>

<div class="form-row credentials" style="display: none;">
<label for="node-input-apikey"><i class="fa fa-key"></i> API Key</label>
<input type="password" id="node-input-apikey" placeholder="API Key"></input>
Expand Down Expand Up @@ -224,8 +217,6 @@
'service-endpoint' :{value: ""}
},
credentials: {
username: {type:'text'},
password: {type:'password'},
apikey: {type: 'password'}
},
color: "rgb(84,149,230)",
Expand Down
23 changes: 1 addition & 22 deletions services/tone_analyzer/v3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013,2016 IBM Corp.
* Copyright 2013,2022 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,25 +23,14 @@ module.exports = function (RED) {
serviceutils = require('../../utilities/service-utils'),
payloadutils = require('../../utilities/payload-utils'),
toneutils = require('../../utilities/tone-utils'),
username = '', password = '', sUsername = '', sPassword = '',
apikey = '', sApikey = '',
endpoint = '',
sEndpoint = 'https://gateway.watsonplatform.net/tone-analyzer/api',
service = null;

// Require the Cloud Foundry Module to pull credentials from bound service
// If they are found then they are stored in sUsername and sPassword, as the
// service credentials. This separation from sUsername and username to allow
// the end user to modify the node credentials when the service is not bound.
// Otherwise, once set username would never get reset, resulting in a frustrated
// user who, when he errenously enters bad credentials, can't figure out why
// the edited ones are not being taken.

service = serviceutils.getServiceCreds(SERVICE_IDENTIFIER);

if (service) {
sUsername = service.username ? service.username : '';
sPassword = service.password ? service.password : '';
sApikey = service.apikey ? service.apikey : '';
sEndpoint = service.url;
}
Expand All @@ -57,15 +46,10 @@ module.exports = function (RED) {
var checkCreds = function(credentials) {
var taSettings = {};

username = sUsername || credentials.username;
password = sPassword || credentials.password;
apikey = sApikey || credentials.apikey;

if (apikey) {
taSettings.iam_apikey = apikey;
} else if (username && password) {
taSettings.username = username;
taSettings.password = password;
} else {
taSettings = null;
}
Expand Down Expand Up @@ -110,9 +94,6 @@ module.exports = function (RED) {

if (settings.iam_apikey) {
authSettings.apikey = settings.iam_apikey;
} else {
authSettings.username = settings.username;
authSettings.password = settings.password;
}

serviceSettings.authenticator = new IamAuthenticator(authSettings);
Expand Down Expand Up @@ -196,8 +177,6 @@ module.exports = function (RED) {

RED.nodes.registerType('watson-tone-analyzer-v3', Node, {
credentials: {
username: {type:'text'},
password: {type:'password'},
apikey: {type:'password'}
}
});
Expand Down

0 comments on commit f6fe6d0

Please sign in to comment.