简体   繁体   English

(PassportJS) 页面未路由到登录页面

[英](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.

相关问题 使用PassportJS和dynamoDB的Express App定位到登录页面而没有错误 - Express App using PassportJS and dynamoDB locates to login page without error 需要重定向到Google App电子邮件登录页面,而不是password.js和nodejs中的普通gmail登录 - Need to redirect to google app email login page instead of normal gmail login in passportjs and nodejs 没有angular-route的angularjs登录页面 - Login Page with angularjs without angular-route Angular Route Guard - 未正确重定向到登录页面 - Angular Route Guard - Not redirecting to login page correctly 私有路由不会重定向到登录页面 - Private route doesnt redirect to login page React - 登录后路由返回到所需页面 - React - Route return to desired page after login 还有其他方法可以验证登录页面和路由 - Is there any other way to authentication the login page and route 登录页面不会重定向到路由到登录页面 - Login page won't redirect to route to logged-in page 使用Passportjs刷新页面后保持身份验证 - Staying authenticated after the page is refreshed using Passportjs 在登录页面上反应受保护的路由问题而无需注销重定向 - React protected route Issue without logout redirect on Login page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM