根据用户是否已经登录来切换登录/注销 [英] Toggle Login/Logout based on if user is already logged in

查看:91
本文介绍了根据用户是否已经登录来切换登录/注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有戏! Web应用程序.如果用户已登录,我想在顶部菜单中显示注销"链接.如果用户未登录,我想隐藏注销"链接,而是显示登录"链接.容易吧?但是,我找不到有关如何实际执行此操作的信息.

I have a Play! web application. If the user is logged in, I would like to show a "Logout" link in the top menu. If the user is not logged in, I'd like to hide the "Logout" link and show a "Login" link instead. Easy, right? However, I am unable to find information on how to actually do this.

那么,我将如何处理呢?我以yabe网络应用程序为例.是否有一个等效的#{secure.check}来检查用户是否已经登录?最简单的方法是什么?

So, how would I go about this? I used the yabe web app as an example. Is there a #{secure.check} equivalent to check if the user has already logged in? What's the easiest way?

我们将不胜感激,这真让我发疯!

Help would be greatly appreciated, this is driving me nuts!

推荐答案

非常简单:

#{if session.connected()}

这篇关于根据用户是否已经登录来切换登录/注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆