Home

014


April 30, 2020


Reinstituted passport.js as the authentication system for my app. Added an html page for the auth callback, as the discord auth flow seems to necessitate some front end code. Looking further into passport, it appears passport manages sessions itself. This caused me to question if express-sessions was even necessary, and after a bit of research, I determined that it is. Express-sessions IS necessary, as defined and described by this article. Also, huge takeaway from this article: “I highly highly recommend going through all your middleware one at a time to understand everything your app is doing on every request. There are many performance gains to be had when you understand things piece by piece.”

In refactoring the code, I removed node-fetch and form-data from my server and the test project dependencies, and removed the scratch project altogether.

After writing all the code to implement passport, I committed and pushed the update to the server where I merged the branch and attempted to run the app. No success. I was missing code where the database interactions would be done. Rather than simply placing dummy code, I opted to write out the model I would use to query the users collection. Huge thanks to this resource for not only helping me understand some aspects of passport, but also discover a better idea of how to go about querying and/or inserting users. After taking some time to think about the approach, and to gain a better understanding of (de)serialization in passport, I think I’ve written a model that will work for the time being, while I work out the remaining pieces of the auth flow. Unfortunately, I’ve run into a series of bugs that are preventing me from thoroughly testing this model.

That’s okay. All in all, I feel I accomplished much, and am looking forward to the work I’ll do tomorrow to test the model I’ve developed.

Comments? Follow me on twitter and drop me a line in response to this tweet:

Day 014: I broke my site again. That’s fun. But that’s what this is all about: breaking shit and learning. Re-implemented @passportjs and am learning how to write database interactions. This link does work:https://t.co/tcFD1uKXQE#nonsensemod365 #thatCodingLife pic.twitter.com/xAd1akPz7A

— Joshua Alexander (@nonsensecodes) April 30, 2020