Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how we can use requestPassword? #4

Open
A1Gard opened this issue Oct 16, 2020 · 4 comments
Open

how we can use requestPassword? #4

A1Gard opened this issue Oct 16, 2020 · 4 comments

Comments

@A1Gard
Copy link

A1Gard commented Oct 16, 2020

My sample:


window.FakeTerminal.command.ops = function (instance) {

        //  Extend the base command
        window.FakeTerminal.command.apply(this, arguments);

        var base = this;

        base.info = function () {
            return {
                private: false,
                description: 'This command doesn\'t do anything terribly exciting'
            };
        };


        base.execute = function (foo, bar) {
            instance.output.write('The value of foo is: ' + foo);
            instance.output.write('The value of bar is: ' + bar);
            base.deferred.resolve();
            var xx = '';
            var ss = instance.input.requestPassword(xx);
            return base.deferred.promise();
        };

        return base;
    };

What's the problem?

@oxmc
Copy link

oxmc commented Dec 16, 2021

@A1Gard have you figured this out yet?
@hellopablo how do we check the value of the password?

@oxmc
Copy link

oxmc commented Dec 16, 2021

@A1Gard i found the solution:

window.FakeTerminal.command.shutdown = function (instance) {
  window.FakeTerminal.command.apply(this, arguments);
  var base = this;
  base.info = function () {
    return {
      private: false,
      description: 'This command shuts the os down.'
    };
  };
  base.execute = function () {
    instance.output.write(`<question>Please enter your password:</question>`);
    instance.input.request("password").done(function(value) {
      if (value == "AtyysCyBDnESysTmsT1000") {
        instance.output.write(`<info>Initiating shutdown sequence...</info>`);
        base.deferred.resolve();
      } else {
        instance.output.write(`<error>ERROR: Aborting shutdown sequence.</error>`);
        instance.output.write(`<error>ERROR: Incorrect password.</error>`);
        base.deferred.resolve();
      };
    }).fail(function() {
      instance.output.write("ERROR FATAL");
      base.deferred.resolve();
    });
    return base.deferred.promise();
  };
  return base;
};

@hellopablo
Copy link
Owner

Thanks @oxmc - sorry @A1Gard I've not had/made time to look at this repository in years (literally).

I do want to revisit this project and bring it to the modern world... one day 😅

@oxmc
Copy link

oxmc commented Dec 16, 2021

@hellopablo if you do look into the repo, please create a docs site, like xterm.js

So users can refer to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants