Manual authentication check Symfony 2

后端 未结 5 1387
我在风中等你
我在风中等你 2021-02-01 07:53

I\'m working on a Symfony 2 application where the user must select a profile during the login process.

Users may have multiples profiles to work with and they only know

5条回答
  •  耶瑟儿~
    2021-02-01 08:21

    The only way I could authenticate my users on a controller is by making a subrequest and then redirecting. Here is my code, I'm using silex but you can easily adapt it to symfony2:

    $subRequest = Request::create($app['url_generator']->generate('login_check'), 'POST', array('_username' => $email, '_password' => $password, $request->cookies->all(), array(), $request->server->all());
    
    $response = $app->handle($subRequest, HttpKernelInterface::MASTER_REQUEST, false);
    
    return $app->redirect($app['url_generator']->generate('curriculos.editar'));
    

提交回复
热议问题