meteor/accounts-base/accounts_server.js
function () {
    var self = this;
    var user = Meteor.users.findOne(self.userId, {
      fields: { "services.resume.loginTokens": 1 }
    });
    if (! self.userId || ! user) {
      throw new Meteor.Error("You are not logged in.");
    }
    // Be careful not to generate a new token that has a later
    // expiration than the curren token. Otherwise, a bad guy with a
    // stolen token could use this method to stop his stolen token from
    // ever expiring.
    var currentHashedToken = Accounts._getLoginToken(self.connection.id);
    var currentStampedToken = _.find(
      user.services.resume.loginTokens,
      function (stampedToken) {
        return stampedToken.hashedToken === currentHashedToken;
      }
    );
    if (! currentStampedToken) { // safety belt: this should never happen
      throw new Meteor.Error("Invalid login token");
    }
    var newStampedToken = Accounts._generateStampedLoginToken();
    newStampedToken.when = currentStampedToken.when;
    Accounts._insertLoginToken(self.userId, newStampedToken);
    return loginUser(self, self.userId, newStampedToken);
  }
function () {
    var self = this;
    var user = Meteor.users.findOne(self.userId, {
      fields: { "services.resume.loginTokens": 1 }
    });
    if (! self.userId || ! user) {
      throw new Meteor.Error("You are not logged in.");
    }
    // Be careful not to generate a new token that has a later
    // expiration than the curren token. Otherwise, a bad guy with a
    // stolen token could use this method to stop his stolen token from
    // ever expiring.
    var currentHashedToken = Accounts._getLoginToken(self.connection.id);
    var currentStampedToken = _.find(
      user.services.resume.loginTokens,
      function (stampedToken) {
        return stampedToken.hashedToken === currentHashedToken;
      }
    );
    if (! currentStampedToken) { // safety belt: this should never happen
      throw new Meteor.Error("Invalid login token");
    }
    var newStampedToken = Accounts._generateStampedLoginToken();
    newStampedToken.when = currentStampedToken.when;
    Accounts._insertLoginToken(self.userId, newStampedToken);
    return loginUser(self, self.userId, newStampedToken);
  }
function ( ) { var self = this ; var user = Meteor . users . findOne ( self . userId , { fields : { "services.resume.loginTokens" : 1 } } ) ; if ( ! self . userId || ! user ) { throw new Meteor . Error ( "You are not logged in." ) ; } // Be careful not to generate a new token that has a later // expiration than the curren token. Otherwise, a bad guy with a // stolen token could use this method to stop his stolen token from // ever expiring. var currentHashedToken = Accounts . _getLoginToken ( self . connection . id ) ; var currentStampedToken = _ . find ( user . services . resume . loginTokens , function ( stampedToken ) { return stampedToken . hashedToken === currentHashedToken ; } ) ; if ( ! currentStampedToken ) { // safety belt: this should never happen throw new Meteor . Error ( "Invalid login token" ) ; } var newStampedToken = Accounts . _generateStampedLoginToken ( ) ; newStampedToken . when = currentStampedToken . when ; Accounts . _insertLoginToken ( self . userId , newStampedToken ) ; return loginUser ( self , self . userId , newStampedToken ) ; }
Generates a new login token with the same expiration as the connection's current token and saves it to the database. Associates the connection with this new token and returns it. Throws an error if called on a connection that isn't logged in.  @returns Object If successful, returns { token: <new token>, id: <user id>, tokenExpires: <expiration date> }.
Generates a new login token with the same expiration as the connection s current token and saves it to the database . Associates the connection with this new token and returns it . Throws an error if called on a connection that isn t logged in .