1
我使用的是SfGuardPlugin和我的网站的后端我有完整的用户列表,我希望能够在用户的前端登录我从列表中选择。Symfony 1.4 - 从后端登录到前端(作为客户端)
我试过这个方法:
public function executeListLogin(sfWebRequest $request) {
// client that I've selected from list
$client = $this->getRoute()->getObject();
// create instance if doesn't exist
if(!sfContext::hasInstance('frontend')){
sfContext::createInstance(ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false));
}
// switch to frontend
sfContext::switchTo('frontend');
// also tried with: sfContext::getInstance('frontend')
sfContext::getInstance()->getUser()->signin($client->getSfGuardUser(), true);
// redirect to frontend homepage
$this->redirect('@homepage');
}
它重定向我到前端的主页,但我没有登录
更多的挖掘后,我发现,我从后端注销,现在我在前端使用管理员而不是我选择的用户登录。所以sfContext :: switchTo不能正常工作。