eZ Platform Discussions

Articles that are displayed differently depending on the user account


#1

Bonjour,

I have articles that can be free or paid for.
I have 3 types of users.

  • Anonymous. Who only sees the beginning of the article and the login form.
  • Not a subscriber. Who only sees the beginning of the article and a link to the subscription
  • Subscriber who sees the full article.

My site is on a cluster enterprise platform.sh with fastly.

Currently, when an anonymous user consults a paid article and then connects with a subscriber account, the user reviews the article in anonymous view…

I probably misconfigured the response header of my page.

How to configure them correctly?

class ArticleController extends Controller
{
    public function fullAction(ContentView $view)
    {
        // Anonymous / Not a subscriber / Subscriber ?
        $view->addParameters(['mode'  => 'anonyme']);

        // Set custom header for the Response
        $response = new Response();
        $response->setVary('X-User-Hash');
        $response->headers->set('X-Location-Id', $view->getLocation()->id);
        $response->setSharedMaxAge(3600);
        $view->setResponse($response);
        return $view;
    }
}