简体   繁体   English

如何检查访问者是否从 plush 模板登录? 使用 go Buffalo 框架

[英]How can I checked if the visitor is logged in from a plush template? Using the go Buffalo framework

How can I check if a visitor is logged in from within a template using the Go Buffalo web framework?如何检查访客是否使用 Go Buffalo web 框架从模板中登录? Specifically, I am working on a project that utilizes the Buffalo framework and I need to be able to determine if a user is currently logged in or not, and I would like to do this within one of my templates.具体来说,我正在开发一个使用 Buffalo 框架的项目,我需要能够确定用户当前是否登录,我想在我的一个模板中执行此操作。 Are there any built-in methods or functions provided by Buffalo that can be used to accomplish this task?是否有 Buffalo 提供的任何内置方法或函数可用于完成此任务?

I found out that I can use current_user , like this我发现我可以像这样使用current_user

<div class="auth-center">
  <%= if (current_user) { %>
    <h1><%= current_user.email %></h1>
    <a href="/signout" data-method="delete">sign out</a>
  <% } else { %>
    <a href="/signin" class="btn btn-primary">sign in</a>
    <a href="/users/new" class="btn btn-success">register</a>
  <% } %>
</div>

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

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