src/services/auth.js
function useAccessAuth() {
  return new Promise((resolve, reject) => {
    if (!defaults.accessToken) {
      reject(__generateFakeResponse__(0, '', {}, 'accessToken is missing for Access authentication'))
    }
    else {
      let details = {
        "token_type": "",
        "expires_in": 0,
        "appName": defaults.appName,
        "username": "",
        "role": "",
        "firstName": "",
        "lastName": "",
        "fullName": "",
        "regId": 0,
        "userId": null
      };
      var aToken = defaults.accessToken.toLowerCase().startsWith('bearer') ? defaults.accessToken : 'Bearer ' + defaults.accessToken;
      utils.storage.set('user', {
        token: {
          Authorization:  aToken,
          appName: defaults.appName
        },
        details: details
      });
      resolve(__generateFakeResponse__(200, 'OK', {}, details, {}));
    }
  });

}
function useAccessAuth() {
  return new Promise((resolve, reject) => {
    if (!defaults.accessToken) {
      reject(__generateFakeResponse__(0, '', {}, 'accessToken is missing for Access authentication'))
    }
    else {
      let details = {
        "token_type": "",
        "expires_in": 0,
        "appName": defaults.appName,
        "username": "",
        "role": "",
        "firstName": "",
        "lastName": "",
        "fullName": "",
        "regId": 0,
        "userId": null
      };
      var aToken = defaults.accessToken.toLowerCase().startsWith('bearer') ? defaults.accessToken : 'Bearer ' + defaults.accessToken;
      utils.storage.set('user', {
        token: {
          Authorization:  aToken,
          appName: defaults.appName
        },
        details: details
      });
      resolve(__generateFakeResponse__(200, 'OK', {}, details, {}));
    }
  });

}
function useAccessAuth ( ) { return new Promise ( ( resolve , reject ) => { if ( ! defaults . accessToken ) { reject ( __generateFakeResponse__ ( 0 , '' , { } , 'accessToken is missing for Access authentication' ) ) } else { let details = { "token_type" : "" , "expires_in" : 0 , "appName" : defaults . appName , "username" : "" , "role" : "" , "firstName" : "" , "lastName" : "" , "fullName" : "" , "regId" : 0 , "userId" : null } ; var aToken = defaults . accessToken . toLowerCase ( ) . startsWith ( 'bearer' ) ? defaults . accessToken : 'Bearer ' + defaults . accessToken ; utils . storage . set ( 'user' , { token : { Authorization : aToken , appName : defaults . appName } , details : details } ) ; resolve ( __generateFakeResponse__ ( 200 , 'OK' , { } , details , { } ) ) ; } } ) ; }
A function that sets the authorization in the storage and therefore in the header as Access Token auth, the credentials are inserted in the init config.
A function that sets the authorization in the storage and therefore in the header as Access Token auth the credentials are inserted in the init config .