[英](PassportJS) page not route to login page
Thank you in advance for helping.预先感谢您的帮助。 I am new to using PassportJS and trying to use it to build a user sign up and login feature.
我不熟悉使用 PassportJS 并尝试使用它来构建用户注册和登录功能。 I used the following tutorial and have some questions regarding the step 12. https://github.com/GM456742/PassportJS_Auth_Tutorial
我使用了以下教程并对步骤 12 有一些疑问。https://github.com/GM456742/PassportJS_Auth_Tutorial
app.post("/api/signup", function(req, res) {
console.log(req.body);
db.User.create({
email: req.body.email,
password: req.body.password
}).then(function() {
res.redirect(307, "/api/login");
}).catch(function(err) {
console.log(err);
res.json(err);
// res.status(422).json(err.errors[0].message);
});
});
//
On that post method for signup, what does it directs users to the member page instead of the login page after the user has signed up?在注册的帖子方法中,它是如何在用户注册后将用户定向到会员页面而不是登录页面的? What should be changed if I want it to direct users to the login page after the user has signed up?
如果我希望它在用户注册后将用户定向到登录页面,应该更改什么?
I tried changing the redirect from res.redirect(307, "/api/login");我尝试从 res.redirect(307, "/api/login"); 更改重定向to res.redirect("login");
到 res.redirect("登录"); and it stays on the sign up page after user has signed up.
并在用户注册后保留在注册页面上。
Thank you!谢谢!
It's a redirect post request to api/login
and returns a json response: /members
route.这是对
api/login
的重定向发布请求,并返回 json 响应: /members
路由。 You should handle the response from the client and redirect to /members
.您应该处理来自客户端的响应并重定向到
/members
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.