0
in_memory에서 사용자의 db 저장소로 심포니와 함께 제공되는 기존 데모 로그인을 수정하려고합니다. "사용자 제공 업체가 UserInterface 객체를 반환해야합니다"오류가 발생합니다. 나는 아직도 점점 오전 : 오류 Symfony2 로그인
[2013-03-27 19:24:34] security.INFO: Authentication request failed: The user provider must return a UserInterface object. [] []
그래서 나는 변경 : 그것이로
'use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* Pouzivatel
*
* @ORM\Table('pouzivatel')
* @ORM\Entity
*/
class Pouzivatel implements UserInterface
.etc
왼쪽 컨트롤러 :
security.yml
providers:
user_db:
entity: { class: Cremesk\AgentisBundle\Entity\Pouzivatel, property: meno }
은 또한 엔티티를 언급 생성
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Security\Core\SecurityContext;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use JMS\SecurityExtraBundle\Annotation\Secure;
/**
* @Route("/demo/secured")
*/
class SecuredController extends Controller
{
/**
* @Route("/login", name="_demo_login")
* @Template()
*/
public function loginAction()
{
if ($this->get('request')->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $this->get('request')->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = $this->get('request')->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
}
return array(
'last_username' => $this->get('request')->getSession()->get(SecurityContext::LAST_USERNAME),
'error' => $error,
);
}
/**
* @Route("/login_check", name="_security_check")
*/
public function securityCheckAction()
{
// The security layer will intercept this request
}
/**
* @Route("/logout", name="_demo_logout")
*/
public function logoutAction()
{
// The security layer will intercept this request
}
/**
* @Route("/hello", defaults={"name"="World"}),
* @Route("/hello/{name}", name="_demo_secured_hello")
* @Template()
*/
public function helloAction($name)
{
return array('name' => $name);
}
/**
* @Route("/hello/admin/{name}", name="_demo_secured_hello_admin")
* @Secure(roles="ROLE_ADMIN")
* @Template()
*/
public function helloadminAction($name)
{
return array('name' => $name);
}
}
로그인을 할 수 없습니다. 도움을 주셔서 감사합니다. 고맙습니다.
이 날 menioned 문제를 해결하는 데 도움을 주었다. 이제 잘못된 자격 증명 로그인 오류가 발생합니다. 지금이 문제를 해결하려고 노력해야합니다. – martin