The prompt can be a function:
var login = false;
var terminal = $('#jq_terminal').terminal(function(command, term) {
term.echo("you just typed " + command);
}, {
login: f_login,
greetings: "You are authenticated",
prompt: function(callback) {
callback(login ? '#' : '$');
},
name: 'shell',
onBlur: function() {
return false;
}
});
you can also use terminal.set_prompt('#');
. You can't access terminal in login function the code code should do authenticate.apply(self, ....)
so you can do this.set_prompt
(I need to fix that) but you should be able to access terminal if you assing it to var like you did (and I in example code). So this should work:
function f_login_response(user, password, callback) {
terminal.set_prompt('$');
//or
login = true;
}
Also if you want to have two type of commands for logged in users and guests then you can do something like:
function(commad, term) {
var cmd = $.terminal.parseCommand(command); // parseCommand is helper that process command line (you have also splitCommand that don't convert to numbers and regexes
if (cmd.name == 'login') {
term.push(function(command) {
term.echo("You type normal command");
}, {
prompt: '#'
// I need to add login option to `push` so you can do term.push('foo.php', {login:true});
}).login(function(user, password, callback) {
if (<< User ok >>) {
callback('TOKEN');
} else {
callback(null); // callback have also second parameter if you use true it will not give error message
}
});
} else {
term.echo("You type guest command");
}
}
PS: in unix $
for normal users and #
is for root.
EDIT: From version 0.8.3 you can call:
term.push('rpc_service.php', {login: true});
and
login(user, pass, callback) {
this.set_prompt('#');
}