Skip to content

Commit

Permalink
login fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rabchev committed Sep 24, 2013
1 parent f790bb2 commit 2be4ffa
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions lib/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ function initialize(server, options, fn) {
replSrv,
user,
username;
function execCmd(command, buffered) {

function execCmd(command, shell) {
if (env.WEBT_LOGIN && !user) {
socket.emit("exit", "login required");
return;
Expand All @@ -151,11 +151,11 @@ function initialize(server, options, fn) {
opts.uid = user;
}

if (env.WEB_SHELL) {
proc = spawn(env.WEB_SHELL, null, opts);
if (env.WEB_SHELL || shell) {
proc = spawn(env.WEB_SHELL || shell, null, opts);
stdin = proc.stdin;
stdin.write(command + linebreak);
//stdin.end();
stdin.write(command);
stdin.end();
} else {
proc = spawn(cmd, args, opts);
stdin = proc.stdin;
Expand All @@ -178,7 +178,7 @@ function initialize(server, options, fn) {
socket.emit("console", data);
});

proc.on("close", function () {
proc.on("close", function (code, signal) {
stdin = null;
socket.emit("exit", "");
});
Expand Down Expand Up @@ -315,8 +315,15 @@ function initialize(server, options, fn) {
}
break;
case "echo":
execCmd(command, process.platform === "win32" ? "cmd" : "bash");
break;
case "login":
case "logout":
user = undefined;
username = undefined;
env.WEBT_LOGIN = "login";
socket.emit("configure", { prompt: "", promptChar: ">" });
socket.emit("username");
default:
execCmd(command);
}
Expand Down

0 comments on commit 2be4ffa

Please sign in to comment.