[英]node/passportjs how to update homepage with welcome user, after logging in and redirect
So after landing on the home page, click to sign in, redirect home and at the top I want it to now show the 'welcome [user]'. 因此,登录到主页后,单击登录并重定向主页,然后在顶部让我现在显示“欢迎[用户]”。 How do i do that?
我怎么做? Basically change from 'login here' to 'welcome user and sign out' after logging in. I want to add this:
登录后,基本上从“在此处登录”更改为“欢迎用户并注销”。我想添加以下内容:
h1.text-center.login-title Welcome #{user.firstName}.
To my current html/jade after logging in: 登录到我当前的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
This is quite simple to do with Pug. 这对Pug非常简单。 When you render, simply pass the username to pug and handle it like so:
渲染时,只需将用户名传递给pug并按以下方式进行处理:
if user.firstName
h1.text-center.login-title Welcome #{user.firstName}.
else
h1.text-center.login-title Please Login
Read more here: https://pugjs.org/language/conditionals.html 在此处阅读更多信息: https : //pugjs.org/language/conditionals.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.