login.js (1085B)
1 2 window.FakeTerminal.command.login = function (instance) { 3 window.FakeTerminal.command.apply(this, arguments); 4 5 const base = this; 6 7 base.info = () => { 8 return { 9 description: "Login into an existing account" 10 } 11 } 12 13 base.execute = () => { 14 let username; 15 let password; 16 17 instance.output.write("Username: ") 18 instance.input.request("text").done((value) => { 19 username = value; 20 21 instance.input.request("password").done( async (value) => { 22 password = value; 23 24 if (await login(username, password)) { 25 window.location = "/"; 26 } else { 27 instance.output.write("<comment>Username / password combination is wrong</comment>"); 28 } 29 30 base.deferred.resolve(); 31 }); 32 }).fail(() => { 33 instance.output.write("<error>Something went wrong.</error>") 34 base.deferred.resolve(); 35 }); 36 37 return base.deferred.promise(); 38 } 39 40 return base; 41 }