When i edit in constructor file of my custom module it give me this error " Type Error occurred when creating object " i don't know what i am doing wrong i use same code for creating a Block and its working.
My Controller code is :
<?php
namespace Dealers\Validation\Controller\Valuation;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\App\Action\Context;
class Index extends \Magento\Framework\App\Action\Action
{
protected $_customerSession;
public function __construct(
\Magento\Customer\Model\SessionFactory $customerSession,
array $userdata = []
) {
$this->_customerSession = $customerSession->create();
parent::__construct($context, $userdata);
}
public function execute()
{
/*if(!$this->_customerSession->isLoggedIn()) {
$this->redirect->redirect($controller->getResponse(), 'customer/account/login');
}*/
$this->_view->loadLayout();
$this->_view->renderLayout();
}
}
I want to redirect it to login page if user is not logged in.