Skip to content

Commit

Permalink
fix: Basic authentication with saved connections
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaysreedhar committed Sep 10, 2023
1 parent 2fa9114 commit d84b704
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/workbench/controllers/client-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,12 @@ export default function ClientSetupController(scope, restClient, viewFrame, toas
const encoded = btoa(`${credentials.username}:${credentials.password}`);

options.headers['Authorization'] = `Basic ${encoded}`;
scope.setupModel.basicAuth.credentials = encoded;
}
setupModel.basicAuth.credentials = encoded;

} else if (typeof setupModel.basicAuth.credentials === 'string' && setupModel.basicAuth.credentials.length >= 1) {
options.headers['Authorization'] = `Basic ${setupModel.basicAuth.credentials}`;
}

const request = restClient.request(options);

request.then(({data: response}) => {
Expand Down Expand Up @@ -196,9 +199,12 @@ export default function ClientSetupController(scope, restClient, viewFrame, toas

const fields = Object.keys(scope.connectionList[connectionId]);

scope.credentials.username = '';
scope.credentials.password = '';
scope.setupModel.id = connectionId;

for (let field of fields) {
scope.setupModel[field] = scope.connectionList[connectionId][field];
scope.setupModel.id = connectionId;
}

return scope.attemptConnection({target: {nodeName: '__none__'}});
Expand Down

0 comments on commit d84b704

Please sign in to comment.