简体   繁体   English

TYPO3 v10.2:自定义身份验证服务中的前端用户会话保存($GLOBALS['TSFE']->fe_user)

[英]TYPO3 v10.2: Frontend user session saving ($GLOBALS['TSFE']->fe_user) in Custom Authentication Service

Right now I am upgrading an old pibased Extension from 6.2 to an extbase 10.2 Extension.现在我正在将旧的 pibased 扩展从 6.2 升级到 extbase 10.2 扩展。 After some research I found out that the Request Workflow for Frontend Requests has changed in TYPO3 10.0 (Issue #88540).经过一些研究,我发现前端请求的请求工作流程在 TYPO3 10.0(问题 #88540)中发生了变化。 From the Changelog:来自更新日志:

TSFE is instantiated after all site resolving, authentication, page resolving and argument validation is done. TSFE 在所有站点解析、身份验证、页面解析和参数验证完成后实例化。

Since I used to store user sessions in $GLOBALS['TSFE']->fe_user with $GLOBALS['TSFE']->fe_user->setKey('ses','key', $value) while authentication process (Custom authService) I am not able to store it anymore because of the changed request workflow.因为我曾经在$GLOBALS['TSFE']->fe_user使用$GLOBALS['TSFE']->fe_user->setKey('ses','key', $value)在身份验证过程中存储用户会话(自定义 authService ) 由于更改了请求工作流程,我无法再存储它。 $GLOBALS['TSFE']->fe_user is now instantiated after the authentication process. $GLOBALS['TSFE']->fe_user现在在身份验证过程后实例化。 It seems like that saving frontend user session has to be moved into Middleware (found some Information here: Task #88541).似乎必须将保存前端用户会话移到中间件中(在此处找到一些信息:任务 #88541)。 Since I never dealt with Middlewares, my Question now is how I can achive saving my frontend user session data by using a middleware Class?由于我从未处理过中间件,我现在的问题是如何使用中间件类来保存前端用户会话数据? Under Configuration\\RequestMiddlewares.php I got following config:Configuration\\RequestMiddlewares.php我得到以下配置:

return [
    'frontend' => [
        'my-middleware-identifier' => [
            'target' => \Vendor\Extension\Middleware\Session::class,
            'after' => [
                'typo3/cms-frontend/prepare-tsfe-rendering'
            ]
        ]
    ]
];

Thanks in advance!提前致谢!

Since TYPO3 v10.0.0 the Request Workflow for Frontend Requests has changed.从 TYPO3 v10.0.0 开始,前端请求的请求工作流程发生了变化。 That's why it isn't possible anymore to store session data during the authentication process.这就是为什么在身份验证过程中不再可能存储会话数据的原因。 See: Changed Request Workflow for Frontend Requests I used a custom middleware for this to store it after the $GLOBALS['TSFE']->fe_user has been created.请参阅: 更改前端请求的请求工作流程我使用了自定义中间件来存储它在$GLOBALS['TSFE']->fe_user创建之后。

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

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