简体   繁体   English

Typo3 Extbase丢失fe_user身份验证

[英]Typo3 Extbase losing fe_user authentication

I have this little snippet for logging in a user with my own Typo3 extension: 我有这个小片段,用于使用我自己的Typo3扩展名登录用户:

$GLOBALS['TSFE']->fe_user->createUserSession(array());
$GLOBALS['TSFE']->fe_user->user = $GLOBALS['TSFE']->fe_user->getRawUserByUid($this->userRepository->findByUsername($winAcc)->toArray()[0]->getUid());
$GLOBALS['TSFE']->fe_user->fetchGroupData();
$GLOBALS['TSFE']->loginUser = 1;

In the fluid template I can check if a user is logged in with this: 在流体模板中,我可以检查用户是否使用此身份登录:

<f:security.ifAuthenticated>
  This is being shown whenever a FE user is logged in
</f:security.ifAuthenticated>

However this code works only for the next action which is executed in the controller. 但是,此代码仅适用于在控制器中执行的下一个动作。 When the FrontEnd User reloads the page, the authentication is lost and also $GLOBALS["TSFE"]->loginUser is null. 当FrontEnd User重新加载页面时,身份验证将丢失,并且$ GLOBALS [“ TSFE”]-> loginUser为null。

Why is this happening? 为什么会这样呢?

Okey, I have the solution for this problem. Okey,我有解决这个问题的方法。 In Typo3 6.2 LTS there seems to be a different cookie handling. 在Typo3 6.2 LTS中,似乎存在不同的cookie处理。 The cookie fe_user cookie is not being set. 未设置cookie fe_user cookie。 Use any method of TSFE to force typo3 to set this cookie. 使用TSFE的任何方法强制typo3设置此cookie。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM