Edit: full code Differs slightly from above because I've tried a couple of things since.
<?php
namespace ..\Subscription\Controller\Index;
use \Magento\Framework\App\Action\Action;
class Index extends Action implements \Magento\Framework\DataObject\IdentityInterface
{
/** @var \Magento\Framework\View\Result\Page */
protected $resultPageFactory;
/**
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Customer\Model\Session $sessionSession
*/
public function __construct(\Magento\Framework\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Magento\Customer\Model\Session $sessionSession)
{
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
$this->_customerSession = $sessionSession;
}
/**
* Subscription Index, shows overview of their subscriptions.
*
* @return \Magento\Framework\View\Result\PageFactory
*/
public function execute()
{
// Check the user is logged in
if($this->_customerSession->isLoggedIn()){
return $this->resultPageFactory->create();
}
else {
return $this->_redirect('customer/account/login');
}
}
/**
* Return identifiers for produced content
*
* @return array
*/
public function getIdentities()
{
return [\..\Subscription\Model\Post::CACHE_TAG . '_' . 'list'];
}
}