防止缓存登录信息 [英] Prevent to Cache Login Information
问题描述
我正在使用 femanager 来管理用户注册,登录和注销.
I'am using femanager to manage user registration, login and logout.
与其他许多网站一样,我想在页面顶部显示一些用户信息(使用Boostraps mini-navbar ).
Like many other websites, I'd like to show some user information on the top of the page (using Boostraps mini-navbar).
- 如果用户已注销,则应如下所示:
- 如果用户已登录,则应显示以下信息:
作为Typo3的初学者,我使用Typo脚本和Fluid Template中的局部代码实现了这一点.Typo脚本读取当前用户(用户ID和电子邮件地址).
As a Typo3 beginner, I implement this with Typo Script and a partial in Fluid Template. The Typo Script reads the current user (user id and e-mail address).
userdata = COA_INT
userdata {
10 = TEXT
10.data = TSFE:fe_user|user|uid
20 = TEXT
20.data = TSFE:fe_user|user|username
}
Partial使用用户ID来检查用户是否已登录.
The partial uses the user id to check if the user is logged in or logged out.
<f:if condition="{f:cObject(typoscriptObjectPath: 'userdata.10')} > 0">
<f:then>
<!-- user is logged in -->
<span class="greeting">
<i class="fa fa-user"></i> <f:cObject typoscriptObjectPath="userdata.20" />
</span>
<f:link.page pageUid="319" additionalParams="{logintype: 'logout'}" class="pull-right"><i class="fa fa-power-off"></i> Logout</f:link.page>
</f:then>
<f:else>
<!-- user is logged out -->
<span class="greeting">
Test it for free
</span>
<f:link.page pageUid="317" class="pull-right"><i class="fa fa-arrow-circle-down"></i> Register</f:link.page>
<f:link.page pageUid="319" class="pull-right"><i class="fa fa fa-sign-in"></i> Log in</f:link.page>
</f:else>
</f:if>
这可以正常工作,但是我在缓存方面遇到了问题.有时,迷你导航栏会显示给另一个用户.
This works OK but I have problems with caching. Sometimes the mini-navbar is shown for an other user.
我的问题是:如何防止部分缓存?
推荐答案
部分"中的缓存有时会比较棘手..
Caching in Partials can be tricky sometimes..
看看VHS viewhelper集合中的安全性viewhelper.它具有一些不错的功能,可以满足您的情况:
Take a look at the security viewhelper within the VHS viewhelper collection. It has some nice functionality which covers your case:
<v:security.allow anyFrontendUser="TRUE">
<f:then><!-- protected information displayed --></f:then>
<f:else><!-- link to login form displayed --></f:else>
</v:security.allow>
有关详细信息,请参见文档.
See the documenation for more information.
这篇关于防止缓存登录信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!