lib/jitsu/commands/users.js
function setupUserNoUsername(callback) {
    //
    // Attempt to get the password three times.
    //
    var tries = 0;

    function offerReset (username) {
      jitsu.prompt.get(['reset'], function (err, res) {
        if (err) {
          return callback(err);
        }
        if (/^y[es]+/i.test(res['request password reset'])) {
          return jitsu.plugins.cli.executeCommand(['users', 'forgot', username ], callback);
        }

        callback(new Error('Invalid username / password.'));
      });
    }

    (function setupAuth () {
      jitsu.prompt.get(['password'], function (err, result) {
        if (err) {
          return callback(err);
        }

        jitsu.config.set('username', username);
        jitsu.config.set('password', result.password);
        jitsu.setup(function () {
          jitsu.auth(function (err) {
            //
            // Increment the auth attempts
            //
            tries += 1;

            if (err) {
              if (tries >= 3) {
                jitsu.log.error('Three failed login attempts');
                jitsu.log.info('Reset the password?');
                return offerReset(username);
              }
              return setupAuth();
            }
            // once password is entered checkout a token and clear out password 
            jitsu.tokens.create(username, (jitsu.config.get('apiTokenName')||'jitsu'), function(err, result) {
              if(!err && result) {
                var token = Object.getOwnPropertyNames(result).filter(function(n){return n !== 'operation'}).pop();
                jitsu.config.set('apiToken', result[token]);
                jitsu.config.set('apiTokenName', token);
                jitsu.config.clear('password');
                jitsu.config.save(function (err) {
                  return err ? callback(err) : callback();
                });
              }
            });
          });
        });
      });
    })();
  }
function setupUserNoUsername(callback) {
    //
    // Attempt to get the password three times.
    //
    var tries = 0;

    function offerReset (username) {
      jitsu.prompt.get(['reset'], function (err, res) {
        if (err) {
          return callback(err);
        }
        if (/^y[es]+/i.test(res['request password reset'])) {
          return jitsu.plugins.cli.executeCommand(['users', 'forgot', username ], callback);
        }

        callback(new Error('Invalid username / password.'));
      });
    }

    (function setupAuth () {
      jitsu.prompt.get(['password'], function (err, result) {
        if (err) {
          return callback(err);
        }

        jitsu.config.set('username', username);
        jitsu.config.set('password', result.password);
        jitsu.setup(function () {
          jitsu.auth(function (err) {
            //
            // Increment the auth attempts
            //
            tries += 1;

            if (err) {
              if (tries >= 3) {
                jitsu.log.error('Three failed login attempts');
                jitsu.log.info('Reset the password?');
                return offerReset(username);
              }
              return setupAuth();
            }
            // once password is entered checkout a token and clear out password 
            jitsu.tokens.create(username, (jitsu.config.get('apiTokenName')||'jitsu'), function(err, result) {
              if(!err && result) {
                var token = Object.getOwnPropertyNames(result).filter(function(n){return n !== 'operation'}).pop();
                jitsu.config.set('apiToken', result[token]);
                jitsu.config.set('apiTokenName', token);
                jitsu.config.clear('password');
                jitsu.config.save(function (err) {
                  return err ? callback(err) : callback();
                });
              }
            });
          });
        });
      });
    })();
  }
function setupUserNoUsername ( callback ) { // // Attempt to get the password three times. // var tries = 0 ; function offerReset ( username ) { jitsu . prompt . get ( [ 'reset' ] , function ( err , res ) { if ( err ) { return callback ( err ) ; } if ( / ^y[es]+ / i . test ( res [ 'request password reset' ] ) ) { return jitsu . plugins . cli . executeCommand ( [ 'users' , 'forgot' , username ] , callback ) ; } callback ( new Error ( 'Invalid username / password.' ) ) ; } ) ; } ( function setupAuth ( ) { jitsu . prompt . get ( [ 'password' ] , function ( err , result ) { if ( err ) { return callback ( err ) ; } jitsu . config . set ( 'username' , username ) ; jitsu . config . set ( 'password' , result . password ) ; jitsu . setup ( function ( ) { jitsu . auth ( function ( err ) { // // Increment the auth attempts // tries += 1 ; if ( err ) { if ( tries >= 3 ) { jitsu . log . error ( 'Three failed login attempts' ) ; jitsu . log . info ( 'Reset the password?' ) ; return offerReset ( username ) ; } return setupAuth ( ) ; } // once password is entered checkout a token and clear out password  jitsu . tokens . create ( username , ( jitsu . config . get ( 'apiTokenName' ) || 'jitsu' ) , function ( err , result ) { if ( ! err && result ) { var token = Object . getOwnPropertyNames ( result ) . filter ( function ( n ) { return n !== 'operation' } ) . pop ( ) ; jitsu . config . set ( 'apiToken' , result [ token ] ) ; jitsu . config . set ( 'apiTokenName' , token ) ; jitsu . config . clear ( 'password' ) ; jitsu . config . save ( function ( err ) { return err ? callback ( err ) : callback ( ) ; } ) ; } } ) ; } ) ; } ) ; } ) ; } ) ( ) ; }
This is like setupUserNoWarn except that it only asks for your password.
This is like setupUserNoWarn except that it only asks for your password .