简体   繁体   English

Passport.js 不工作,但注册是

[英]Passport.js not working, but registration is

I'm trying to reinforce some concepts learned in Colt Steele's Web Development Bootcamp and I have built a small website.我正在尝试加强在 Colt Steele 的 Web 开发训练营中学到的一些概念,并且我已经建立了一个小型网站。 At this time, I'm just trying to get the authentication working properly.目前,我只是想让身份验证正常工作。

When a user signs up, I can see that they are added to my Mongo DB so I'm assuming that is working correctly but when I try to log back in it always redirects to the error page.当用户注册时,我可以看到他们已添加到我的 Mongo DB 中,所以我假设它工作正常,但是当我尝试重新登录时,它总是重定向到错误页面。

I have tried debugging this a number of ways and have compared it to the work we did in the course a hundred times but I cannot spot the bug with this.我已经尝试了多种调试方法,并将它与我们在课程中所做的工作进行了一百次比较,但我无法发现这个错误。 If anyone could give me some guidance I would really appreciate it.如果有人能给我一些指导,我将不胜感激。

Here's my project repo:这是我的项目回购:

https://github.com/mcarre93/Depa https://github.com/mcarre93/Depa

Ciao, according ti passport docs , when you post /login you should do: Ciao,根据 ti passport docs ,当您发布/login时,您应该:

app.post('/login', passport.authenticate('local'), function(req, res) {
     // If this function gets called, authentication was successful.
     // `req.user` contains the authenticated user.
     res.redirect('/account');
});

I read your code and you are doing something different.我读了你的代码,你正在做一些不同的事情。 Try to modify your code as documentation suggest and let me know.尝试按照文档建议修改您的代码并告诉我。

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

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