src/api/auth.js
function () {
    // Get stored auth data.
    var stored = this.storage.get();

    // If nothing stored, proceed with new authorization
    if (!stored) {
      this.log('No auth data stored, starting authorization from scratch...');
      return this.auth.authorize();
    }

    // Otherwise, set the auth data on the Request object so that it can be used for requests
    this.log('Auth data stored, checking validity...');
    this._auth = utils.unserialize(stored);

    // Use the saved auth data to check if we're already authorized. If not, it will clear the stored
    // data, then proceed with new authorization.
    return this.auth.isAuth()
      .then(function(result) {
        if (result === false)
          return this.auth.authorize();
      }.bind(this));
  }
function () {
    // Get stored auth data.
    var stored = this.storage.get();

    // If nothing stored, proceed with new authorization
    if (!stored) {
      this.log('No auth data stored, starting authorization from scratch...');
      return this.auth.authorize();
    }

    // Otherwise, set the auth data on the Request object so that it can be used for requests
    this.log('Auth data stored, checking validity...');
    this._auth = utils.unserialize(stored);

    // Use the saved auth data to check if we're already authorized. If not, it will clear the stored
    // data, then proceed with new authorization.
    return this.auth.isAuth()
      .then(function(result) {
        if (result === false)
          return this.auth.authorize();
      }.bind(this));
  }
function ( ) { // Get stored auth data. var stored = this . storage . get ( ) ; // If nothing stored, proceed with new authorization if ( ! stored ) { this . log ( 'No auth data stored, starting authorization from scratch...' ) ; return this . auth . authorize ( ) ; } // Otherwise, set the auth data on the Request object so that it can be used for requests this . log ( 'Auth data stored, checking validity...' ) ; this . _auth = utils . unserialize ( stored ) ; // Use the saved auth data to check if we're already authorized. If not, it will clear the stored // data, then proceed with new authorization. return this . auth . isAuth ( ) . then ( function ( result ) { if ( result === false ) return this . auth . authorize ( ) ; } . bind ( this ) ) ; }
Call this method in order to authenticate with SAFE, using either previous authentication
or new.
@returns {Promise}
Call this method in order to authenticate with SAFE using either previous authentication or new .