We’ve migrated our documentation to a new site, which means some URLs have changed.
Subscriptions

How to check access after a user logs in

By default, Composer is checking access only upon the page load, and not directly after a user's login.

Therefore, it's recommended to implement a reload or a tp.offer.close() method when the loginSuccess callback is fired.

For example like this:

tp = window.tp || [];
// Hook execute when login was successful
tp.push(['addHandler', 'loginSuccess', function () {
  // Get list of all access data
  tp.api.callApi('/access/list', {}, function (data) {
    if (typeof data.data != "undefined") {
      // Loop through all possible access objects
      for (var i in data.data) {
        // Was access granted?
        if (data.data[i].granted) {
          // All good, user just logged in, we can close the offer
          tp.offer.close();
          // Additionally we can refresh the page
          location.reload();
        }
      }
    }
  });
}]);

Last updated: