In this task we will be authenticating the login form using the Zend\Authentication
component using the following steps:
Add a function to return the authentication service in the login controller
src/Users/Controller/LoginController.php
:// References use Zend\Authentication\AuthenticationService; use Zend\Authentication\Adapter\DbTable as DbTableAuthAdapter; // Class definition public function getAuthService() { if (! $this->authservice) { $dbAdapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter'); $dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'user','email','password', 'MD5(?)'); $authService = new AuthenticationService(); $authService->setAdapter($dbTableAuthAdapter); $this->authservice = $authService; } return $this->authservice; }
In the
processAction()
method forLoginController
, check if the form submission is valid, and use theAuthService
method to validate the credentials using...