src/api/auth.js
function () {
    this.log('Checking if authorized...');
    return this.Request.get('/auth').auth().execute()
      // let's use our own function here, that resolve true or false,
      // rather than throwing an error if invalid token
      .then(function () {
        this.log('Authorized');
        return true;
      }.bind(this), function (response) {
        this.log('Not authorized, or received error.', response);
        if (response.status === 401) {
          // Remove any auth from storage and Request class
          this.log('Not authorized, removing any stored auth data.');
          clearAuthData.call(this);

          // Return false
          return false;
        } else {
          // Any other status is another error, throw the response
          throw response;
        }
      }.bind(this));
  }
function () {
    this.log('Checking if authorized...');
    return this.Request.get('/auth').auth().execute()
      // let's use our own function here, that resolve true or false,
      // rather than throwing an error if invalid token
      .then(function () {
        this.log('Authorized');
        return true;
      }.bind(this), function (response) {
        this.log('Not authorized, or received error.', response);
        if (response.status === 401) {
          // Remove any auth from storage and Request class
          this.log('Not authorized, removing any stored auth data.');
          clearAuthData.call(this);

          // Return false
          return false;
        } else {
          // Any other status is another error, throw the response
          throw response;
        }
      }.bind(this));
  }
function ( ) { this . log ( 'Checking if authorized...' ) ; return this . Request . get ( '/auth' ) . auth ( ) . execute ( ) // let's use our own function here, that resolve true or false, // rather than throwing an error if invalid token . then ( function ( ) { this . log ( 'Authorized' ) ; return true ; } . bind ( this ) , function ( response ) { this . log ( 'Not authorized, or received error.' , response ) ; if ( response . status === 401 ) { // Remove any auth from storage and Request class this . log ( 'Not authorized, removing any stored auth data.' ) ; clearAuthData . call ( this ) ; // Return false return false ; } else { // Any other status is another error, throw the response throw response ; } } . bind ( this ) ) ; }
Checks if we're authenticated on the SAFE network
@returns {*}
Checks if we re authenticated on the SAFE network