Doctrine 2 ve ZF2'yi kullanarak kimlik doğrulaması yapmak istiyorum. Yardım almak için Zend 2 + doctrine 2 Auth Adapter'u kullandım, ancak her zaman $authService->authenticate($adapter);
'u aradığımda, '' sınıfının olmadığı bir hata alıyorum.Zend2 + Doctrine2 Kimlik Doğrulama
Modül.config.php 'den yapılan yapılandırmada # t kullanılması gerektiği görülüyor.
'authenticationadapter' => array(
'orm_default' => array(
'objectManager' => 'doctrine.entitymanager.orm_default',
'identityClass' => 'Profile\Entity\User',
'identityProperty' => 'username',
'credentialProperty' => 'password',
),
),
Ama authService bir var_dump yaptıysanız tüm setleri boş şunlardır: Şöyle gösterir. Ben giriş yapmak istiyorum benim hizmetinde ben $ authAdapter A dökümü IdentityValue ve CredentialValue doğru ayarlanmış söylüyor
$authAdapter = $this->getAuthAdapter();
$authAdapter->setIdentityValue($username);
$authAdapter->setCredentialValue($password);
diyoruz.
$ authAdabter diğer şeyler şunlardır:
protected 'options' =>
object(DoctrineModule\Options\Authentication)[281]
protected 'objectManager' =>
object(Doctrine\ORM\EntityManager)[248]
private 'config' =>
object(Doctrine\ORM\Configuration)[250]
...
private 'conn' =>
object(Doctrine\DBAL\Connection)[252]
...
private 'metadataFactory' =>
object(Doctrine\ORM\Mapping\ClassMetadataFactory)[266]
...
private 'repositories' =>
array (size=0)
...
private 'unitOfWork' =>
object(Doctrine\ORM\UnitOfWork)[267]
...
private 'eventManager' =>
object(Doctrine\Common\EventManager)[242]
...
private 'hydrators' =>
array (size=0)
...
private 'proxyFactory' =>
object(Doctrine\ORM\Proxy\ProxyFactory)[268]
...
private 'expressionBuilder' => null
private 'closed' => boolean false
private 'filterCollection' => null
protected 'objectRepository' => null
protected 'identityClass' => null
protected 'identityProperty' => null
protected 'credentialProperty' => null
protected 'credentialCallable' => null
protected 'classMetadata' => null
protected 'storage' => null
protected '__strictMode__' => boolean true
protected 'authenticationResultInfo' => null
getAuthAdapter böyle gösteriyor:
public function getAuthAdapter()
{
if (null === $this->authAdapter) {
$this->authAdapter = $this->getServiceManager()
->get('doctrine.authenticationadapter.ormdefault');
}
return $this->authAdapter;
}
Yani bazı biri nasıl doğru seçenekleri ayarlamak için bana söyleyebilir?
Tamam ben değiştirin:
Sonrada benzer bir şekilde denetleyici kullanmak şöyledir: 'zfcuser_auth_service' ile değiştirin Doktrin kimlik kullanmak BjyAuthorize almak (veya ekleme) için ama şimdi bana diyor ki 'Zend \ ServiceManager \ ServiceManager :: get doctrine.authentication.orm_default' için bir örnek getiremedi veya oluşturamadı. Getter'i "public function getAuthAdapter() { { $ this-> authAdapter = $ this-> getServiceManager() -> get ('doctrine.authentication] olarak değiştiririm .orm_default '); } dönüş $ this-> authAdapter; –
Güncelleştirme yanıtı gör – hohner
Yardımlarınız için teşekkür ederiz. Şimdi sadece bir problem kaldı. $ AuthResult = $ authService-> authenticate(); 'Boş bir sayfa alıyorum. Hata yok, hiçbir şey. –