Skip to content

Commit

Permalink
Ssh Auth uiux
Browse files Browse the repository at this point in the history
  • Loading branch information
veniware committed May 20, 2024
1 parent 351a47f commit a1f6d89
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
9 changes: 7 additions & 2 deletions Protest/Front/ssh.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class Ssh extends Terminal {
}

okButton.onclick = ()=> {
this.params.username = usernameInput.value.trim();

if (rememberPasswordCheckBox.checked) {
this.params.password = passwordInput.value;
}
Expand All @@ -95,7 +97,6 @@ class Ssh extends Terminal {
hostInput.onkeydown = usernameInput.onkeydown = passwordInput.onkeydown = event=> {
if (dialog.okButton.disabled) return;
if (event.key === "Enter") {
this.params.username = usernameInput.value.trim();
dialog.okButton.click();
}
};
Expand Down Expand Up @@ -178,7 +179,11 @@ class Ssh extends Terminal {
this.content.focus();
}
else if (json.error) {
setTimeout(()=>{ this.ConfirmBox(json.error, true, "mono/error.svg"); }, 200);
setTimeout(()=>{
this.ConfirmBox(json.error, true, "mono/error.svg").addEventListener("click", ()=> {
setTimeout(()=>this.ConnectDialog(this.params.host, false), 200);
});
}, 200);
}
};
}
Expand Down
4 changes: 1 addition & 3 deletions Protest/Front/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ class Terminal extends Window {
this.cursorElement.style.top = Terminal.CURSOR_HEIGHT * this.cursor.y + "px";

if (this.params.autoScroll) {
this.cursorElement.scrollIntoView();
setTimeout(()=>this.cursorElement.scrollIntoView(), 250);
}
}

Expand Down Expand Up @@ -575,8 +575,6 @@ class Terminal extends Window {
const sequence = data.slice(index + 2, end);
const [command, ...params] = sequence.split(";");

console.log(command, params);

switch (command) {
case "0":
case "2": //set title
Expand Down
6 changes: 6 additions & 0 deletions Protest/Protocols/Ssh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Threading.Tasks;
using Protest.Http;
using Renci.SshNet;
using Renci.SshNet.Common;

namespace Protest.Protocols;

Expand Down Expand Up @@ -95,6 +96,11 @@ public static async void WebSocketHandler(HttpListenerContext ctx) {
shellStream.Write(Encoding.ASCII.GetString(buff, 0, receiveResult.Count));
}
}
catch (SshAuthenticationException) {
await WsWriteText(ws, "{\"error\":\"Invalid username or password\"}");
await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, String.Empty, CancellationToken.None);
return;
}
catch (SocketException ex) {
await WsWriteText(ws, $"{{\"error\":\"{ex.Message}\"}}");
await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, String.Empty, CancellationToken.None);
Expand Down

0 comments on commit a1f6d89

Please sign in to comment.