sharetribe / web-template

Sharetribe Web Template - starting point to create a client app to your marketplace
Other
31 stars 136 forks source link

Private marketplace mode. #434

Closed Gnito closed 3 months ago

Gnito commented 3 months ago

This allows you to make your marketplace private.

Upcoming API Impact

When the marketplace is set to private, the following API endpoints become restricted:

Affected public routes on template

The following public routes are impacted and become private:

Behavioral changes when private marketplace is enabled

SEO considerations

Notes

It's also possible that the access-control.json asset is out of sync! This can happen because there's a cache on live environments. In addition, a client app fetches it only on full page load.

To test how the app handles out-of-sync scenarios:

  1. Ensure the marketplace is public.
  2. Reload the client app (to load the current access-control.json asset).
  3. Switch the marketplace to private.
  4. Click on links leading to the SearchPage, ListingPage, or ProfilePage. Depending on the user's authentication & state, different results should appear.

About implementation:

The routeConfiguration.js needs info from /general/access-control.json asset. If the marketplace has "private" flag on, it adds auth:true flag to the aforementioned routes.

Then the affected pages (SearchPage, ListingPage, and ProfilePage) a) restrict what data they fetch on loadData b) redirect users to Signup or NoAccessPage depending on the private marketplace mode & error thrown by API.

On client-side rendering, there's fetch for the currentUser entity and it's enforced to happen before loadData call is made. However, on SSR the currentUser entity is not fetched. (We try to avoid the SSR from being user-specific.)