Prompt when already logged in
This commit is contained in:
parent
ddcf7f5865
commit
94f3721bf8
|
@ -48,7 +48,12 @@ function SSHClient(clientConn) {
|
|||
|
||||
function terminateConnection() {
|
||||
ctx.reject();
|
||||
clientConn.end();
|
||||
return clientConn.end();
|
||||
}
|
||||
|
||||
function alreadyLoggedIn(username) {
|
||||
ctx.prompt(`${username} is already connected to the system. Terminating connection.\n(Press any key to continue)`);
|
||||
return terminateConnection();
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -65,15 +70,13 @@ function SSHClient(clientConn) {
|
|||
userLogin(self, ctx.username, ctx.password, function authResult(err) {
|
||||
if(err) {
|
||||
if(err.existingConn) {
|
||||
// :TODO: Can we display somthing here?
|
||||
terminateConnection();
|
||||
return;
|
||||
} else {
|
||||
return alreadyLoggedIn(username);
|
||||
}
|
||||
|
||||
return ctx.reject(SSHClient.ValidAuthMethods);
|
||||
}
|
||||
} else {
|
||||
|
||||
ctx.accept();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if(-1 === SSHClient.ValidAuthMethods.indexOf(ctx.method)) {
|
||||
|
@ -85,7 +88,7 @@ function SSHClient(clientConn) {
|
|||
return ctx.reject();
|
||||
}
|
||||
|
||||
let interactivePrompt = { prompt : `${ctx.username}'s password: `, echo : false };
|
||||
const interactivePrompt = { prompt : `${ctx.username}'s password: `, echo : false };
|
||||
|
||||
ctx.prompt(interactivePrompt, function retryPrompt(answers) {
|
||||
loginAttempts += 1;
|
||||
|
@ -93,12 +96,13 @@ function SSHClient(clientConn) {
|
|||
userLogin(self, username, (answers[0] || ''), err => {
|
||||
if(err) {
|
||||
if(err.existingConn) {
|
||||
// :TODO: can we display something here?
|
||||
terminateConnection();
|
||||
} else {
|
||||
return alreadyLoggedIn(username);
|
||||
}
|
||||
|
||||
if(loginAttempts >= Config.general.loginAttempts) {
|
||||
terminateConnection();
|
||||
} else {
|
||||
return terminateConnection();
|
||||
}
|
||||
|
||||
const artOpts = {
|
||||
client : self,
|
||||
name : 'SSHPMPT.ASC',
|
||||
|
@ -117,8 +121,6 @@ function SSHClient(clientConn) {
|
|||
}
|
||||
return ctx.prompt(interactivePrompt, retryPrompt);
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ctx.accept();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue