我正在使用安全模块,如果我的标题不清楚: http : //www.playframework.org/documentation/1.2.4/secure
(安全控制器驻留在(标准)控制器包中)
我在main.html模板中有这个:
#{if Security.isConnected != true} <a href="#" id="loginSlider">Login</a> #{/if} #{else} <a href="/logout">Logout</a> #{/else}它似乎不起作用,因为“安全”从这里是空的。 我发现在playframework.org上记录得相当糟糕。
[编辑]我尝试过的事情:在Controller前添加@:#{if @ Security.isConnected!= true}使用包名称进行前缀:#{if @ controllers.Security.isConnected!= true}
我已经通过导航到安全页面验证我确实登录了。
[EDIT2]找到了可行的解决方法,但我不喜欢它。 基本上,安全控制器方法isConnected执行此操作:return session.contains(“username”)。 所以我可以在我看来检查:
#{ifnot session.contains("username")}
但它不是最佳解决方案......
I'm using the Secure module if that wasn't clear from my title: http://www.playframework.org/documentation/1.2.4/secure
(The Security controller resides in the (standard) controllers package)
I have this in my main.html template:
#{if Security.isConnected != true} <a href="#" id="loginSlider">Login</a> #{/if} #{else} <a href="/logout">Logout</a> #{/else}And it doesn't seem to work as "Security" is null from here. I've found it to be fairly poorly documented on playframework.org.
[EDIT] Things I've tried: Adding a @ in front of the Controller: #{if @Security.isConnected != true} Prefixing with package name: #{if @controllers.Security.isConnected != true}
I've verified that I am indeed logged in by navigating to a secure page.
[EDIT2] Found a workaround that works, but I dislike it. Basically, the Security controller method isConnected does this: return session.contains("username"). So I can do that check in my view:
#{ifnot session.contains("username")}
But its not the optimal solution...
最满意答案
#{ifnot controllers.Security.isConnected()} <a href="#" id="loginSlider">Login</a> #{/ifnot} #{else} <a href="/logout">Logout</a> #{/else} #{ifnot controllers.Security.isConnected()} <a href="#" id="loginSlider">Login</a> #{/ifnot} #{else} <a href="/logout">Logout</a> #{/else}更多推荐
发布评论