Jump to content

kostor

Member
  • Content Count

    33
  • Joined

  • Last visited

  • Medals

Posts posted by kostor


  1.        // functions change prompt of command line to login to password
           // and call user login function with callback that set token
           // if user call it with value that is true
           function login() {
               var user = null;
               command_line.prompt('login: ');
               // don't stor logins in history
               if (settings.history) {
                   command_line.history().disable();
               }
               command_line.commands(function(command) {
                   try {
                       echo_command(command);
                       if (!user) {
                           user = command;
                           command_line.prompt('password: ');
                           command_line.mask(true);
                       } else {
                           command_line.mask(false);
                           self.pause();
                           if (typeof settings.login !== 'function') {
                               throw "Value of login property must be a function";
                           }
                           var passwd = command;
                           settings.login(user, passwd, function(token) {
                               if (token) {
                                   var name = settings.name;
                                   name = (name ? '_' + name : '');
                                   $.Storage.set('token' + name, token);
                                   $.Storage.set('login' + name, user);
                                   //restore commands and run interpreter
                                   command_line.commands(commands);
                                   // move this to one function init.
                                   initialize();
                               } else {
                                   self.error('Wrong password try again');
                                   command_line.prompt('login: ');
                                   user = null;
                               }
                               self.resume();
                               if (settings.history) {
                                   command_line.history().enable();
                               }
                           });
                       }
                   } catch (e) {
                       display_exception(e, 'LOGIN', self);
                       throw e;
                   }
               });
           }
    

    This is the login function. I bet some of you noticed it, but let's check it again.

    Ahhh.. also try CTRL+R. for a sec it activated a reverse search or something like that...

×