Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 角色为_ADMIN的登录错误没有路由_Php_Mysql_Security_Symfony_Login - Fatal编程技术网

Php 角色为_ADMIN的登录错误没有路由

Php 角色为_ADMIN的登录错误没有路由,php,mysql,security,symfony,login,Php,Mysql,Security,Symfony,Login,我写了一个用户提供程序和注册,效果很好 但是,当我直接使用sequel pro将用户角色从role_user更改为role_ADMIN(仅用于测试)时,我无法登录,并收到错误消息: 无法为命名路由“登录”生成URL,因为该路由不存在 当我切换回角色_USER时,登录就像一个符咒 这是我的安全。yml: security: encoders: AppBundle\Entity\User: algorithm: bcrypt provide

我写了一个用户提供程序和注册,效果很好

但是,当我直接使用sequel pro将用户角色从role_user更改为role_ADMIN(仅用于测试)时,我无法登录,并收到错误消息:

无法为命名路由“登录”生成URL,因为该路由不存在

当我切换回角色_USER时,登录就像一个符咒

这是我的安全。yml:

security:

    encoders:
        AppBundle\Entity\User:
            algorithm: bcrypt

    providers:
        users:
            entity:
                class:    AppBundle:User

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt|error)|css|images|js)/
            security: false

        default:
            pattern:  ^/
            provider: users
            anonymous: ~
            form_login:
                check_path:          login_check
                login_path:          login
                default_target_path: profile_index
            logout:
                path:   logout
                target: profile_index
我是否必须定义我能够使用角色为\ u ADMIN的用户登录的任何内容

如果您需要更多信息,请告诉我

编辑:

这是我的用户控制器:

/**
 * Class UserController
 * @Route(path="/user")
 */
class UserController extends Controller
{
  /**
   * @Route(path="/sign-up", name="user_signup")
   * @Method({ "GET", "POST" })
   */
  public function signUpAction(Request $request)
  {
    $form = $this->createForm('registration');
    $form->handleRequest($request);

    if ($form->isValid()) {
      $user = $form->getData();

      $this->get('registration_handler')
        ->createUser($user);

      return $this->redirectToRoute('profile_index');
    }

    return $this->render('User/signUp.html.twig', array(
      'form' => $form->createView()
    ));
  }

  /**
   * @Route(path="/login", name="user_login")
   */
  public function loginAction(Request $request)
  {
    $helper = $this->get('security.authentication_utils');

    return $this->render('User/login.html.twig', array(
      'last_username' => $helper->getLastUsername(),
      'error' => $helper->getLastAuthenticationError()
    ));
  }

  /**
   * @Route("/login-check", name="login_check")
   * @Method("POST")
   */
  public function loginCheckAction()
  {
    throw new \Exception('This should never be reached!');
  }

  /**
   * @Route("/logout", name="logout")
   * @Method("GET")
   */
  public function logoutAction()
  {
    throw new \Exception('This should never be reached!');
  }

  /**
   * @Route(path="/profile", name="user_profile")
   */
  public function profileAction()
  {
    return $this->render('User/profile.html.twig');
  }
}
我刚刚添加了security.yml

role_hierarchy:
    ROLE_ADMIN:       ROLE_USER

但这并没有改变任何事情

我没有在我的路线中定义任何路线。yml(这就是其中的全部内容):

我只是在登录路径的security.yml中写错了路径

很抱歉。好的

我只是在登录路径的security.yml中写错了路径


很抱歉。

您可以添加您的登录路由定义吗?如果您有任何访问控制?您应该阅读第页,尤其是第…部分。我在错误的凭据中遇到相同的错误…您可以添加您的登录路由定义吗?如果您有任何访问控制,您应该阅读第页,特别是第…部分,我用错误的凭据得到相同的错误…你能添加你的登录路由定义吗?如果你有任何访问控制?你应该阅读页面,特别是第…部分,我用错误的凭据得到相同的错误。。。
access_control:
    - { path: ^/user, roles: [ROLE_USER, ROLE_ADMIN] }
app:
    resource: "@AppBundle/Controller/"
    type:     annotation