FOSUserBundle 自动验证具有 SUPER_ADMIN 权限的用户
FOSUserBundle automatically authenticate user with SUPER_ADMIN privileges
在我的申请中,来自 FOSUserBundle
的 path: /login
要求 User
提供凭据以验证他的身份。
我想将身份验证行为更改为非标准:
每当需要身份验证时,使用 SUPER_ADMIN
权限自动对用户进行身份验证(重定向或跳过登录)。
在 Symfony 2 中正确的做法是什么?
先重写 FOSUserBundle SecurityController,然后修改 loginAction 方法;
public function loginAction(Request $request)
{
$user = new User("yourmail@sd.com", "your_pwd", "ROLE_SUPER_ADMIN");
$token = new UsernamePasswordToken($user, $user->getPassword(),'your_security_provider_name', $user->getRoles());
$this->get('security.token_storage')->setToken($token);
return $this->redirectToRoute('your_custom_route_name');
}
在我的申请中,来自 FOSUserBundle
的 path: /login
要求 User
提供凭据以验证他的身份。
我想将身份验证行为更改为非标准:
每当需要身份验证时,使用 SUPER_ADMIN
权限自动对用户进行身份验证(重定向或跳过登录)。
在 Symfony 2 中正确的做法是什么?
先重写 FOSUserBundle SecurityController,然后修改 loginAction 方法;
public function loginAction(Request $request)
{
$user = new User("yourmail@sd.com", "your_pwd", "ROLE_SUPER_ADMIN");
$token = new UsernamePasswordToken($user, $user->getPassword(),'your_security_provider_name', $user->getRoles());
$this->get('security.token_storage')->setToken($token);
return $this->redirectToRoute('your_custom_route_name');
}