src/dropbox.js
function (settings) {
    // We only update this.userAddress if settings.userAddress is set to a string or to null:
    if (typeof settings.userAddress !== 'undefined') { this.userAddress = settings.userAddress; }
    // Same for this.token. If only one of these two is set, we leave the other one at its existing value:
    if (typeof settings.token !== 'undefined') { this.token = settings.token; }

    var writeSettingsToCache = function() {
      if (hasLocalStorage) {
        localStorage.setItem(SETTINGS_KEY, JSON.stringify({
          userAddress: this.userAddress,
          token: this.token
        }));
      }
    };

    var handleError = function() {
      this.connected = false;
      if (hasLocalStorage) {
        localStorage.removeItem(SETTINGS_KEY);
      }
    };

    if (this.token) {
      this.connected = true;
      if (this.userAddress) {
        this._emit('connected');
        writeSettingsToCache.apply(this);
      } else {
        this.info().then(function (info){
          this.userAddress = info.email;
          this._emit('connected');
          writeSettingsToCache.apply(this);
        }.bind(this)).catch(function() {
          handleError.apply(this);
          this.rs._emit('error', new Error('Could not fetch user info.'));
        }.bind(this));
      }
    } else {
      handleError.apply(this);
    }
  }
function (settings) {
    // We only update this.userAddress if settings.userAddress is set to a string or to null:
    if (typeof settings.userAddress !== 'undefined') { this.userAddress = settings.userAddress; }
    // Same for this.token. If only one of these two is set, we leave the other one at its existing value:
    if (typeof settings.token !== 'undefined') { this.token = settings.token; }

    var writeSettingsToCache = function() {
      if (hasLocalStorage) {
        localStorage.setItem(SETTINGS_KEY, JSON.stringify({
          userAddress: this.userAddress,
          token: this.token
        }));
      }
    };

    var handleError = function() {
      this.connected = false;
      if (hasLocalStorage) {
        localStorage.removeItem(SETTINGS_KEY);
      }
    };

    if (this.token) {
      this.connected = true;
      if (this.userAddress) {
        this._emit('connected');
        writeSettingsToCache.apply(this);
      } else {
        this.info().then(function (info){
          this.userAddress = info.email;
          this._emit('connected');
          writeSettingsToCache.apply(this);
        }.bind(this)).catch(function() {
          handleError.apply(this);
          this.rs._emit('error', new Error('Could not fetch user info.'));
        }.bind(this));
      }
    } else {
      handleError.apply(this);
    }
  }
function ( settings ) { // We only update this.userAddress if settings.userAddress is set to a string or to null: if ( typeof settings . userAddress !== 'undefined' ) { this . userAddress = settings . userAddress ; } // Same for this.token. If only one of these two is set, we leave the other one at its existing value: if ( typeof settings . token !== 'undefined' ) { this . token = settings . token ; } var writeSettingsToCache = function ( ) { if ( hasLocalStorage ) { localStorage . setItem ( SETTINGS_KEY , JSON . stringify ( { userAddress : this . userAddress , token : this . token } ) ) ; } } ; var handleError = function ( ) { this . connected = false ; if ( hasLocalStorage ) { localStorage . removeItem ( SETTINGS_KEY ) ; } } ; if ( this . token ) { this . connected = true ; if ( this . userAddress ) { this . _emit ( 'connected' ) ; writeSettingsToCache . apply ( this ) ; } else { this . info ( ) . then ( function ( info ) { this . userAddress = info . email ; this . _emit ( 'connected' ) ; writeSettingsToCache . apply ( this ) ; } . bind ( this ) ) . catch ( function ( ) { handleError . apply ( this ) ; this . rs . _emit ( 'error' , new Error ( 'Could not fetch user info.' ) ) ; } . bind ( this ) ) ; } } else { handleError . apply ( this ) ; } }
Sets the connected flag
Accepts its parameters according to the <WireClient>.
@param {Object} settings
@param {string} [settings.userAddress] - The user's email address
@param {string} [settings.token] - Authorization token

@protected
Sets the connected flag Accepts its parameters according to the <WireClient > . @param { Object } settings @param { string } [ settings . userAddress ] - The user s email address @param { string } [ settings . token ] - Authorization token