[英]node/passportjs how to update homepage with welcome user, after logging in and redirect
因此,登录到主页后,单击登录并重定向主页,然后在顶部让我现在显示“欢迎[用户]”。 我怎么做? 登录后,基本上从“在此处登录”更改为“欢迎用户并注销”。我想添加以下内容:
h1.text-center.login-title Welcome #{user.firstName}.
登录到我当前的html / jade后:
extends layout
block content
body(style='background-color:black')
p
a.fade(href="#")
img.fade(src='http://data.whicdn.com/images/18140107/large.jpg',
height='150', width='200')
p
ul.centered
li.none
li Chapter 1
li Chapter 2
li Chapter 3
li Chapter 4
li Chapter 5
li Chapter 6
li Chapter 7
li Chapter 8
li Chapter 9
li Chapter 10
这对Pug非常简单。 渲染时,只需将用户名传递给pug并按以下方式进行处理:
if user.firstName
h1.text-center.login-title Welcome #{user.firstName}.
else
h1.text-center.login-title Please Login
在此处阅读更多信息: https : //pugjs.org/language/conditionals.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.