I am a zf1 developer. I started zf2. I am creating a Authentication module. I created a Auth class as mentioned in the doc
<?php
namespace Application\Model;
use Zend\Authentication\Adapter\AdapterInterface;
use Zend\Authentication\Adapter\DbTable as AuthAdapter;
class Myauth implements AdapterInterface {
/**
* Sets username and password for authentication
*
* @return void
*/
public function __construct($username, $password) {
// Configure the instance with constructor parameters...
$authAdapter = new AuthAdapter($dbAdapter,
'users',
'username',
'password'
);
$authAdapter
->setTableName('users')
->setIdentityColumn('username')
->setCredentialColumn('password');
$result = $authAdapter->authenticate();
if (!$result->isValid()) {
// Authentication failed; print the reasons why
foreach ($result->getMessages() as $message) {
echo "$message
";
}
} else {
// Authentication succeeded
// $result->getIdentity() === $username
}
}
}
Issue1 : How to get $dbAdapter here? Issue2 : Is this correct way to create auth module?