2012-12-24 2 views
0

symfony 2.1 설명서에 표시된 로그인 양식을 작성 중입니다. 나는 똑같은 일을하고있다. 나는 간단한 인증에서 성공을 거두었지만 간단한 로그인 양식을 만들 때 login_check 경로를 찾을 수 없다. login_check 경로를 입력하면 login_check 오류가 발생합니다.
문서에 대한 설명이 없습니다. 내 security.yml는Symfony 2.1 보안 로그인 검사 오류

# app/config/security.yml 
security: 
    providers: 
    in_memory: 
     memory: 
      users: 
       ryan: { password: ryanpass, roles: 'ROLE_USER' } 
       admin: { password: kitten, roles: 'ROLE_ADMIN' } 

firewalls: 
    login: 
     pattern: ^/login$ 
     security: false 
    secured_area: 
     pattern: ^/admin 
     anonymous: false 
     form_login: 
      login_path: /login 
      check_path: /login_check 
      always_use_default_target_path: false 
      default_target_path:   /admin/content/index 
      target_path_parameter:   _target_path 
      use_referer:     false 
      username_parameter:    _username 
      password_parameter:    _password 
      csrf_parameter:     login[_token] 
     logout: 
      path: /admin/logout 
      target: /login 
access_control: 
    - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } 
    - { path: ^/admin, roles: ROLE_ADMIN } 

encoders: 
    Symfony\Component\Security\Core\User\User: plaintext 

하고 routing.yml는

login: 
pattern: /login 
defaults: { _controller: AcmeTaskBundle:Default:login} 

login_check: 
pattern: /login_check   
defaults: { _controller: AcmeTaskBundle:Default:loginCheck} 

logout: 
pattern: /admin/logout 
defaults: { _controller: AcmeTaskBundle:Default:logout} 
content_index: 
pattern: /admin/content/index 
defaults: { _controller: AcmeTaskBundle:Default:index } 

내 컨트롤러 로그인 작업을

namespace Acme\TaskBundle\Controller; 
use Symfony\Bundle\FrameworkBundle\Controller\Controller; 
use Symfony\Component\HttpFoundation\Request; 
use Acme\TaskBundle\Entity\Product; 
use Acme\TaskBundle\Entity\CmsContentMst; 
use Acme\TaskBundle\Entity\CmsSectionsMst; 

// use Acme\TaskBundle\Entity\ProductType; 
use Symfony\Component\HttpFoundation\Response; 
use Acme\TaskBundle\Form\Type\AddContent; 
use Symfony\Component\Security\Core\SecurityContext; 

class DefaultController extends Controller 
{ 
public function loginAction() 
{ 
    $request = $this->getRequest(); 
    $session = $request->getSession(); 

    // get the login error if there is one 
    if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) { 
     $error = $request->attributes->get(
      SecurityContext::AUTHENTICATION_ERROR 
     ); 
    } else { 
     $error = $session->get(SecurityContext::AUTHENTICATION_ERROR); 
     $session->remove(SecurityContext::AUTHENTICATION_ERROR); 
    } 

    return $this->render(
     'AcmeTaskBundle:Default:login.html.twig', 
     array(
      // last username entered by the user 
      'last_username' => $session->get(SecurityContext::LAST_USERNAME), 
      'error'   => $error, 
     ) 
    ); 
    } 
public function panelAction(Request $request) 
{ 

} 
public function loginCheckAction() 
    { 

    return new Response('true'); 

    } 

입니다 및 login.html.twig는

{# src/Acme/SecurityBundle/Resources/views/Security/login.html.twig #} 
{% if error %} 
    <div>{{ error.message }}</div> 
{% endif %} 

<form action="{{ path('login_check') }}" method="post"> 
<label for="username">Username:</label> 
<input type="text" id="username" name="_username" value="{{ last_username }}" /> 

<label for="password">Password:</label> 
<input type="password" id="password" name="_password" /> 

{# 
    If you want to control the URL the user is redirected to on success (more details  below) 
    <input type="hidden" name="_target_path" value="/account" /> 
    #} 

<button type="submit">login</button> 
</form> 
입니다

로그인 C에 무엇을 넣어야합니까? heck.controller ... 심포니 2.1에서 누군가가 완전한 로그인 예를 가지고 있다면 대답 해주세요 ..

+1

이 http://stackoverflow.com/questions/13997233/unable-to-find-를 참조하시기 바랍니다 도움이 될 수 등

서비스에 정의 할 수 있습니다/controller-for-path-login-check/13997744 # 13997744 login_check가 컨트롤러를 가리켜서는 안되며 방화벽 패턴 내의 경로 여야합니다. 보안 시스템에 의해 내부적으로 사용되는 경로이지만 경로로도 정의되어야하므로 나뭇 가지'경로'기능을 사용할 수 있습니다 – l3l0

답변