Browse Source

🚚 Rename host 'user' property to 'username'

master
KaKi87 2 months ago
parent
commit
f26e4215fe
4 changed files with 13 additions and 13 deletions
  1. +1
    -1
      lib/account.js
  2. +3
    -3
      lib/ssh.js
  3. +8
    -8
      lib/tui/index.js
  4. +1
    -1
      test/account.js

+ 1
- 1
lib/account.js View File

@ -65,7 +65,7 @@ const Account = function(username, password){
throw new Error('INVALID_ADDRESS');
if(typeof host.port !== 'number' || !Number.isInteger(host.port))
throw new Error('INVALID_PORT');
if(typeof host.user !== 'string')
if(typeof host.username !== 'string')
throw new Error('INVALID_USER');
if(typeof host.password !== 'string')
throw new Error('INVALID_PASSWORD');


+ 3
- 3
lib/ssh.js View File

@ -7,7 +7,7 @@ module.exports = {
for(let i = 0; i < hostsChain.length; i++){
const
prevClient = clients[i-1],
{ address, port, user, password } = hostsChain[i],
{ address, port, username, password } = hostsChain[i],
nextHost = hostsChain[i+1],
client = clients[i] = new Client();
client.on('error', onError);
@ -35,7 +35,7 @@ module.exports = {
if(error) onError(error);
client.connect({
sock: prevClientStream,
username: user,
username,
password
});
});
@ -43,7 +43,7 @@ module.exports = {
else client.connect({
host: address,
port,
username: user,
username,
password
});
});


+ 8
- 8
lib/tui/index.js View File

@ -193,7 +193,7 @@ const getViews = screen => {
height: tableHeight,
columnsWidth: [ 50, 50 ],
headers: [ 'Host', 'URI' ],
data: hosts.map(host => [ host.name, `${host.user}@${host.address}:${host.port}` ])
data: hosts.map(host => [ host.name, `${host.username}@${host.address}:${host.port}` ])
});
selectButton.on('press', () => {
hostsTable.focus();
@ -244,7 +244,7 @@ const getViews = screen => {
else
addButton.focus();
},
setHost: ({ name, address, port, user, password } = {}, callback) => {
setHost: ({ name, address, port, username, password } = {}, callback) => {
let action;
const hostForm = form();
text({ content: 'Add host' }, { borderBottom: true }, hostForm);
@ -256,7 +256,7 @@ const getViews = screen => {
text({ top: n += 4, content: 'Port :' }, hostForm);
textbox({ top: n += 2, name: 'port', content: port }, hostForm);
text({ top: n += 4, content: 'User :' }, hostForm);
const userInput = textbox({ top: n += 2, name: 'user', content: user }, hostForm);
const userInput = textbox({ top: n += 2, name: 'username', content: username }, hostForm);
text({ top: n += 4, content: 'Password :' }, hostForm);
textbox({ top: n += 2, name: 'password', censor: true, content: password }, hostForm);
const actions = flexContainer({ top: n += 4, width: 100 }, hostForm);
@ -281,7 +281,7 @@ const getViews = screen => {
{ color: 'red' },
hostForm
);
hostForm.on('submit', ({ name, address, port, user, password }) => {
hostForm.on('submit', ({ name, address, port, username, password }) => {
port = parseInt(port);
if(action === 'test'){
testButton.setContent('Testing');
@ -290,7 +290,7 @@ const getViews = screen => {
// noinspection JSUnusedGlobalSymbols
callback({
action,
host: { name, address, port, user, password },
host: { name, address, port, username, password },
res: res => {
if(action === 'test'){
testButton.setContent('Test');
@ -301,7 +301,7 @@ const getViews = screen => {
else {
successText.hide();
const error = ({
WRONG_CREDENTIALS: 'wrong user or password',
WRONG_CREDENTIALS: 'wrong username or password',
WRONG_DESTINATION: 'wrong address or port'
})[res];
errorText.setContent(`SSH connection failed : ${error || `unknown error (${res})`}`);
@ -511,9 +511,9 @@ const getControllers = (stream, end) => {
switch(action2){
case 'cancel': return _controllers.main(user);
case 'test': {
const { address, port, user, password } = host2;
const { address, port, username, password } = host2;
ssh.chainedSession(
[{ address, port, user, password }],
[{ address, port, username, password }],
() => res(true),
undefined,
({ level: error }) => {


+ 1
- 1
test/account.js View File

@ -110,7 +110,7 @@ describe('account', () => {
name: 'host',
address: 'host',
port: 22,
user: 'user',
username: 'username',
password: 'password'
};


Loading…
Cancel
Save