从 extbase 设置 fe_users 会话

发布于 2024-12-08 22:21:52 字数 126 浏览 0 评论 0原文

由于我必须以某种方式验证登录数据,普通登录扩展无法处理,因此我必须开发一个自定义登录表单。该登录框是分机的一部分。用 extbase 编写。

但我坚持一个基本问题:我如何处理 extbase 中的 fe_users 会话?

As I have to verify the login-data in a way, normal login extensions can not handle, I have to develop a custom login-form. This login box is part of an ext. written in extbase.

But I stuck with a basic question: How can i handle fe_users sessions in extbase?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

病毒体 2024-12-15 22:21:52

我写了这个 函数,也许它有帮助:

/** @var $fe_user tslib_feUserAuth */
$fe_user = $GLOBALS['TSFE']->fe_user;
$fe_user->createUserSession(array('uid' => $uid));
$fe_user->user = $fe_user->getRawUserByUid($uid);
$fe_user->fetchGroupData();
$GLOBALS['TSFE']->loginUser = 1;

它受到启发通过 Tx_Phpunit_Framework::loginFrontEndUser($userId) :

// Instead of passing the actual user data to createUserSession, we
// pass an empty array to improve performance (e.g. no session record
// will be written to the database).
$GLOBALS['TSFE']->fe_user->createUserSession(array());
$GLOBALS['TSFE']->fe_user->user = $GLOBALS['TSFE']->fe_user->getRawUserByUid($userId);
$GLOBALS['TSFE']->fe_user->fetchGroupData();
$GLOBALS['TSFE']->loginUser = 1;

I wrote this function, maybe it helps:

/** @var $fe_user tslib_feUserAuth */
$fe_user = $GLOBALS['TSFE']->fe_user;
$fe_user->createUserSession(array('uid' => $uid));
$fe_user->user = $fe_user->getRawUserByUid($uid);
$fe_user->fetchGroupData();
$GLOBALS['TSFE']->loginUser = 1;

It's inspired by Tx_Phpunit_Framework::loginFrontEndUser($userId) :

// Instead of passing the actual user data to createUserSession, we
// pass an empty array to improve performance (e.g. no session record
// will be written to the database).
$GLOBALS['TSFE']->fe_user->createUserSession(array());
$GLOBALS['TSFE']->fe_user->user = $GLOBALS['TSFE']->fe_user->getRawUserByUid($userId);
$GLOBALS['TSFE']->fe_user->fetchGroupData();
$GLOBALS['TSFE']->loginUser = 1;
时光清浅 2024-12-15 22:21:52

在 TYPO3 6.2 中,所提供的答案似乎都不适合我。 Forge 中的错误报告中描述了该修复,https://forge.typo3.org/issues/62194< /a> .基本上,SessionCookie 不再自动放置,您现在需要自己执行此操作,

        $reflection = new \ReflectionClass($GLOBALS['TSFE']->fe_user);
        $setSessionCookieMethod = $reflection->getMethod('setSessionCookie');
        $setSessionCookieMethod->setAccessible(TRUE);
        $setSessionCookieMethod->invoke($GLOBALS['TSFE']->fe_user);

在调用 createUserSession() 之后添加。

None of the answers provided seemed to work for me in TYPO3 6.2. The fix is described in a Bugreport in the Forge, https://forge.typo3.org/issues/62194 . Basically, the SessionCookie isn't placed automatically anymore, you need to do that on your own now, adding

        $reflection = new \ReflectionClass($GLOBALS['TSFE']->fe_user);
        $setSessionCookieMethod = $reflection->getMethod('setSessionCookie');
        $setSessionCookieMethod->setAccessible(TRUE);
        $setSessionCookieMethod->invoke($GLOBALS['TSFE']->fe_user);

after calling the createUserSession().

好倦 2024-12-15 22:21:52

我通过组合大量片段终于成功了。这对我来说就是这样的:

$loginData = array(
  'uname' => $loginData['user'],
  'uident' => $loginData['passw'],
  'status' => 'login'
);

$GLOBALS['TSFE']->fe_user->checkPid = 0;
$info = $GLOBALS['TSFE']->fe_user->getAuthInfoArray();
$user = $GLOBALS['TSFE']->fe_user->fetchUserRecord( $info['db_user'], $loginData['uname'] );
if ( $GLOBALS['TSFE']->fe_user->compareUident($user,$loginData) )
{
    $GLOBALS["TSFE"]->fe_user->user = $GLOBALS["TSFE"]->fe_user->fetchUserSession();
    $GLOBALS['TSFE']->loginUser = 1;
    $GLOBALS['TSFE']->fe_user->fetchGroupData(); 
    $GLOBALS['TSFE']->fe_user->start();
    $GLOBALS["TSFE"]->fe_user->createUserSession($user);
    $GLOBALS["TSFE"]->fe_user->loginSessionStarted = TRUE;
}

I finally made it, by combining lots of snippets. Thats how it worked out for me:

$loginData = array(
  'uname' => $loginData['user'],
  'uident' => $loginData['passw'],
  'status' => 'login'
);

$GLOBALS['TSFE']->fe_user->checkPid = 0;
$info = $GLOBALS['TSFE']->fe_user->getAuthInfoArray();
$user = $GLOBALS['TSFE']->fe_user->fetchUserRecord( $info['db_user'], $loginData['uname'] );
if ( $GLOBALS['TSFE']->fe_user->compareUident($user,$loginData) )
{
    $GLOBALS["TSFE"]->fe_user->user = $GLOBALS["TSFE"]->fe_user->fetchUserSession();
    $GLOBALS['TSFE']->loginUser = 1;
    $GLOBALS['TSFE']->fe_user->fetchGroupData(); 
    $GLOBALS['TSFE']->fe_user->start();
    $GLOBALS["TSFE"]->fe_user->createUserSession($user);
    $GLOBALS["TSFE"]->fe_user->loginSessionStarted = TRUE;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文