RichardVargas1 / Project_2_UTHOU201808FSF_p2g4

Repo setup.
1 stars 0 forks source link

Passport Integration #15

Open salilbhise opened 5 years ago

salilbhise commented 5 years ago

Passport is authentication middleware for Node. It is designed to serve a singular purpose: authenticate requests. When writing modules, encapsulation is a virtue, so Passport delegates all other functionality to the application. This separation of concerns keeps code clean and maintainable, and makes Passport extremely easy to integrate into an application.

http://www.passportjs.org/docs/username-password/

https://github.com/jaredhanson/passport-local

$ npm install passport-local

salilbhise commented 5 years ago

Build was successful

salilbhise commented 5 years ago

May need to remove username if it is not needed.

screen shot 2018-12-05 at 6 55 33 am
RichardVargas1 commented 5 years ago

Hey Sal, just realized that maybe this had something to do with the server.js file. Look at the following code:

app.use(passport.initialize()); app.use(passport.session());

app.use(function(req, res, next){ res.locals.isAuthenticated = req.isAuthenticated(); next(); });

I believe we need to require it and initialize it since it isn't being listened to.

RichardVargas1 commented 5 years ago

Currently working on this issue above ^

salilbhise commented 5 years ago

Strong work, @RichardVargas1! I will check into it as well. I am currently isolating Passport code to test Product display from MySQL.

RichardVargas1 commented 5 years ago

Just have to run through some validations and check that routes are in appropriate positions for callbacks.

salilbhise commented 5 years ago

Passport is mostly working, bcrypt-nodejs is hiding the password, and data is being captured in ensights_development. We still need to run the below code once user logs in to compare:

// Load hash from your password DB. bcrypt.compare("bacon", hash, function(err, res) { // res == true }); bcrypt.compare("veggies", hash, function(err, res) { // res = false });

screen shot 2018-12-10 at 2 02 26 pm

screen shot 2018-12-10 at 2 15 35 pm

salilbhise commented 5 years ago

https://www.npmjs.com/package/bcrypt-nodejs