mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-08 21:54:36 +02:00
Wrap ctx.reject() and catch throws
This commit is contained in:
parent
c6e176f5bd
commit
73e8b0454e
1 changed files with 12 additions and 4 deletions
|
@ -49,8 +49,16 @@ function SSHClient(clientConn) {
|
||||||
|
|
||||||
self.log.trace( { method : ctx.method, username : username, newUser : self.isNewUser }, 'SSH authentication attempt');
|
self.log.trace( { method : ctx.method, username : username, newUser : self.isNewUser }, 'SSH authentication attempt');
|
||||||
|
|
||||||
|
const safeContextReject = (param) => {
|
||||||
|
try {
|
||||||
|
return ctx.reject(param);
|
||||||
|
} catch(e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function terminateConnection() {
|
function terminateConnection() {
|
||||||
ctx.reject();
|
safeContextReject();
|
||||||
return clientConn.end();
|
return clientConn.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,19 +114,19 @@ function SSHClient(clientConn) {
|
||||||
return handleSpecialError(err, username);
|
return handleSpecialError(err, username);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.reject(SSHClient.ValidAuthMethods);
|
return safeContextReject(SSHClient.ValidAuthMethods);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.accept();
|
ctx.accept();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if(-1 === SSHClient.ValidAuthMethods.indexOf(ctx.method)) {
|
if(-1 === SSHClient.ValidAuthMethods.indexOf(ctx.method)) {
|
||||||
return ctx.reject(SSHClient.ValidAuthMethods);
|
return safeContextReject(SSHClient.ValidAuthMethods);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(0 === username.length) {
|
if(0 === username.length) {
|
||||||
// :TODO: can we display something here?
|
// :TODO: can we display something here?
|
||||||
return ctx.reject();
|
return safeContextReject();
|
||||||
}
|
}
|
||||||
|
|
||||||
const interactivePrompt = { prompt : `${ctx.username}'s password: `, echo : false };
|
const interactivePrompt = { prompt : `${ctx.username}'s password: `, echo : false };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue