Code Snippets: Password Encryption

Another model I need to use for this web application is for my user's. When someone visits my app I want to ask for username, name, and email. At some point, they should be able to edit their profile to add a picture or an avatar and I definitely want to encrypt their passwords for them. In order to make sure each user has these elements attached to their profile I created a schema, installed a package to handle my encryption, and a package to handle authenticating that password.


I chose bcrypt and Password because that is what I'm familiar with and what we went over in class. However, there are other ways to encrypt passwords and other packages that do it similarly. The userSchema.methods and .statics was all 'boilerplate' code that I was able find in our reading material but if I ever need it again in the future I can either look back on this project or find bcrypt documentation.

My next steps will be routing my login and register pages that I made templates for yesterday!

Comments