title
MEAN Stack Front To Back [Part 3] - User Model & Register

description
In this video we will create our Mongoose user model and schema with the user fields. We will also complete the /register post route to sign up a new user and encrypt passwords with Bcrypt Code Up To This Point: http://www.traversymedia.com/downloads/meanauthapp/meanauthapp_part_3.zip My Courses: http://traversymedia.com/eduonix-courses DONATIONS: Any donation is greatly appreciated.... https://www.paypal.me/traversymedia https://www.patreon.com/traversymedia

detail
{'title': 'MEAN Stack Front To Back [Part 3] - User Model & Register', 'heatmap': [{'end': 560.614, 'start': 538.436, 'weight': 0.912}, {'end': 791.813, 'start': 756.722, 'weight': 1}, {'end': 840.99, 'start': 830.623, 'weight': 0.795}], 'summary': 'Covers setting up an express server, connecting to a mongodb database, and configuring middleware, including creating routes for register, authenticate, profile, and validate. it also delves into creating a user model with fields like name, password, email, and username, using mongoose and bcrypt for encryption, and implementing functions to get user by id and username, and to register a new user with encrypted password.', 'chapters': [{'end': 51.325, 'segs': [{'end': 51.325, 'src': 'embed', 'start': 0.469, 'weight': 0, 'content': [{'end': 4.53, 'text': 'Hey guys, welcome to part three of the mean stack front to back series.', 'start': 0.469, 'duration': 4.061}, {'end': 11.452, 'text': 'In the last video, we went ahead and set up our express server and we connected to our MongoDB database.', 'start': 4.77, 'duration': 6.682}, {'end': 19.414, 'text': 'We also set up all the middleware for our dependencies, for our cores and body parser, things like that.', 'start': 12.432, 'duration': 6.982}, {'end': 22.417, 'text': 'and we also created our routes file.', 'start': 20.194, 'duration': 2.223}, {'end': 28.363, 'text': 'so in routes, users we have our register, authenticate, profile and validate.', 'start': 22.417, 'duration': 5.946}, {'end': 35.43, 'text': 'now, one thing that i forgot to do is register is actually a post route, so we just want to change that to router.post.', 'start': 28.363, 'duration': 7.067}, {'end': 38.473, 'text': "okay, and we don't even need the validate.", 'start': 35.43, 'duration': 3.043}, {'end': 40.255, 'text': 'i had that for some testing.', 'start': 38.473, 'duration': 1.782}, {'end': 40.996, 'text': 'i was doing, so.', 'start': 40.255, 'duration': 0.741}, {'end': 42.177, 'text': "we're going to get rid of that as well.", 'start': 40.996, 'duration': 1.181}, {'end': 48.263, 'text': "That's the only thing that we need to change from what we've already done, I believe.", 'start': 43.82, 'duration': 4.443}, {'end': 51.325, 'text': 'We also set up our database config file.', 'start': 48.844, 'duration': 2.481}], 'summary': 'Part three of mean stack series covered express server setup, mongodb connection, middleware, and route creation.', 'duration': 50.856, 'max_score': 0.469, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/1ZeDy2QI3OE/pics/1ZeDy2QI3OE469.jpg'}], 'start': 0.469, 'title': 'Setting up express server and mongodb database', 'summary': 'Covers setting up an express server and connecting to a mongodb database, configuring middleware, creating routes for register, authenticate, profile, and validate, focusing on adjusting the register route to a post route and removing unnecessary validate route.', 'chapters': [{'end': 51.325, 'start': 0.469, 'title': 'Setting up express server and mongodb database', 'summary': 'Covers setting up an express server and connecting to a mongodb database, configuring middleware, creating routes for register, authenticate, profile, and validate, with a focus on adjusting the register route to a post route and removing unnecessary validate route.', 'duration': 50.856, 'highlights': ['The chapter covers setting up an express server and connecting to a MongoDB database.', 'Configuring middleware for dependencies such as cores and body parser is discussed.', 'Creating routes for register, authenticate, profile, and validate is explained, with a focus on adjusting the register route to a post route and removing unnecessary validate route.', 'The chapter also includes setting up a database config file.']}], 'duration': 50.856, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/1ZeDy2QI3OE/pics/1ZeDy2QI3OE469.jpg', 'highlights': ['Creating routes for register, authenticate, profile, and validate is explained, with a focus on adjusting the register route to a post route and removing unnecessary validate route.', 'The chapter covers setting up an express server and connecting to a MongoDB database.', 'Configuring middleware for dependencies such as cores and body parser is discussed.', 'The chapter also includes setting up a database config file.']}, {'end': 922.151, 'segs': [{'end': 113.873, 'src': 'embed', 'start': 73.599, 'weight': 0, 'content': [{'end': 85.007, 'text': "okay, so we're going to create a folder called models and we're going to create a file in there called user.js.", 'start': 73.599, 'duration': 11.408}, {'end': 91.352, 'text': 'okay, so in here we want to bring in mongoose.', 'start': 85.007, 'duration': 6.345}, {'end': 105.03, 'text': "so we're going to set that to require mongoose And we also want to bring in bcrypt for encryption.", 'start': 91.352, 'duration': 13.678}, {'end': 109.731, 'text': 'And we want to set that to require.', 'start': 107.871, 'duration': 1.86}, {'end': 113.873, 'text': "And we're going to require bcrypt.js because that's what we're using.", 'start': 110.392, 'duration': 3.481}], 'summary': "Creating a 'user.js' file in 'models' folder, importing mongoose and bcrypt for encryption.", 'duration': 40.274, 'max_score': 73.599, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/1ZeDy2QI3OE/pics/1ZeDy2QI3OE73599.jpg'}, {'end': 278.846, 'src': 'embed', 'start': 245.236, 'weight': 1, 'content': [{'end': 249.345, 'text': 'which will take in the name of the model user and then the schema.', 'start': 245.236, 'duration': 4.109}, {'end': 250.748, 'text': 'So user schema.', 'start': 249.666, 'duration': 1.082}, {'end': 255.819, 'text': 'All right.', 'start': 255.578, 'duration': 0.241}, {'end': 267.215, 'text': 'Now I want to create two basic functions in this file, one to get the user by their ID and one to get it by the username.', 'start': 258.106, 'duration': 9.109}, {'end': 275.763, 'text': 'So when we want to use functions outside, we have to do module dot exports and then dot the function name.', 'start': 268.016, 'duration': 7.747}, {'end': 278.846, 'text': "So let's say get user by ID.", 'start': 275.843, 'duration': 3.003}], 'summary': 'Creating two basic functions: get user by id and get user by username in the user schema file.', 'duration': 33.61, 'max_score': 245.236, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/1ZeDy2QI3OE/pics/1ZeDy2QI3OE245236.jpg'}, {'end': 560.614, 'src': 'heatmap', 'start': 538.436, 'weight': 0.912, 'content': [{'end': 546.443, 'text': "except we're going to say success is true, and our message will say user registered.", 'start': 538.436, 'duration': 8.007}, {'end': 552.027, 'text': "OK, so let's save that and now let's create the add user inside of the model.", 'start': 546.463, 'duration': 5.564}, {'end': 560.614, 'text': 'Add user is a function.', 'start': 558.492, 'duration': 2.122}], 'summary': "Defining success as true, with message 'user registered', creating 'add user' function", 'duration': 22.178, 'max_score': 538.436, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/1ZeDy2QI3OE/pics/1ZeDy2QI3OE538436.jpg'}, {'end': 791.813, 'src': 'heatmap', 'start': 756.722, 'weight': 1, 'content': [{'end': 762.546, 'text': "and then we want to add for the headers we're going to have the content type.", 'start': 756.722, 'duration': 5.824}, {'end': 764.107, 'text': "I'm going to submit it as Jason.", 'start': 762.546, 'duration': 1.561}, {'end': 771.872, 'text': "so application dot, slash Jason and then the body I'm going to send raw.", 'start': 764.107, 'duration': 7.765}, {'end': 791.813, 'text': "and let's do actually let's do name, John Doe, email And username.", 'start': 771.872, 'duration': 19.941}], 'summary': 'Headers include content type as application/json and raw submission of name, email, and username.', 'duration': 35.091, 'max_score': 756.722, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/1ZeDy2QI3OE/pics/1ZeDy2QI3OE756722.jpg'}, {'end': 860.164, 'src': 'heatmap', 'start': 830.623, 'weight': 0.795, 'content': [{'end': 832.064, 'text': "that's config database.", 'start': 830.623, 'duration': 1.441}, {'end': 834.126, 'text': 'sorry about that guys.', 'start': 832.064, 'duration': 2.062}, {'end': 835.346, 'text': "hopefully that's it.", 'start': 834.126, 'duration': 1.22}, {'end': 837.988, 'text': "let's go ahead and try the register again.", 'start': 835.346, 'duration': 2.642}, {'end': 840.99, 'text': 'send true user registered.', 'start': 837.988, 'duration': 3.002}, {'end': 848.855, 'text': 'good, so now if we go down here to the mongo shell and say show dbs, we have a mean off database.', 'start': 840.99, 'duration': 7.865}, {'end': 854.578, 'text': "so i'm going to say use mean off and let's say show collections.", 'start': 848.855, 'duration': 5.723}, {'end': 857.461, 'text': "So we have a user's collection.", 'start': 856.099, 'duration': 1.362}, {'end': 860.164, 'text': "And look, we didn't have to even set up this database.", 'start': 857.881, 'duration': 2.283}], 'summary': 'Configured database, registered user, and established collections without setup.', 'duration': 29.541, 'max_score': 830.623, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/1ZeDy2QI3OE/pics/1ZeDy2QI3OE830623.jpg'}, {'end': 912.441, 'src': 'embed', 'start': 862.666, 'weight': 2, 'content': [{'end': 869.954, 'text': 'This is a lot more flexible than something like MySQL, where you would have to go in, create your tables.', 'start': 862.666, 'duration': 7.288}, {'end': 873.678, 'text': "You'd have to create every single column you want along with each field type.", 'start': 869.994, 'duration': 3.684}, {'end': 875.44, 'text': 'This is much more flexible.', 'start': 873.999, 'duration': 1.441}, {'end': 883.684, 'text': "So we can say db.users.find, and then let's add .pretty, which will make it look a little cleaner.", 'start': 876.261, 'duration': 7.423}, {'end': 885.565, 'text': "And there's our guy.", 'start': 884.624, 'duration': 0.941}, {'end': 892.127, 'text': 'So we have our ID, which is an object ID, kind of like a primary key in a relational database.', 'start': 885.605, 'duration': 6.522}, {'end': 896.329, 'text': 'Our name, email, username, and look at the password.', 'start': 892.867, 'duration': 3.462}, {'end': 898.509, 'text': 'The password is now encrypted.', 'start': 896.889, 'duration': 1.62}, {'end': 901.411, 'text': "So we're not storing those plain text passwords.", 'start': 899.11, 'duration': 2.301}, {'end': 902.971, 'text': 'All right.', 'start': 902.651, 'duration': 0.32}, {'end': 905.234, 'text': 'So we now have a registration system.', 'start': 903.072, 'duration': 2.162}, {'end': 907.376, 'text': "So I'm going to cut it here.", 'start': 905.894, 'duration': 1.482}, {'end': 912.441, 'text': "And then in the next video, we're going to set up a passport with a local strap.", 'start': 907.416, 'duration': 5.025}], 'summary': 'Comparison of flexible mongodb with mysql. encrypted passwords. setting up registration system.', 'duration': 49.775, 'max_score': 862.666, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/1ZeDy2QI3OE/pics/1ZeDy2QI3OE862666.jpg'}], 'start': 52.486, 'title': 'Creating user model and functions', 'summary': 'Discusses creating a user model with fields like name, password, email, and username, using mongoose and bcrypt for encryption, and implementing functions to get user by id and username, and to register a new user with encrypted password, making the system more flexible than traditional databases like mysql.', 'chapters': [{'end': 922.151, 'start': 52.486, 'title': 'Creating user model and functions', 'summary': 'Discusses creating a user model with fields like name, password, email, and username, using mongoose and bcrypt for encryption, and implementing functions to get user by id and username, and to register a new user with encrypted password, making the system more flexible than traditional databases like mysql.', 'duration': 869.665, 'highlights': ['The chapter discusses creating a user model with fields like name, password, email, and username, using Mongoose and bcrypt for encryption. The user model is created with fields like name, password, email, and username, and Mongoose and bcrypt are utilized for encryption.', 'The system is more flexible than traditional databases like MySQL, allowing for easier database setup and storage of encrypted passwords. The system is more flexible than traditional databases like MySQL, allowing for easier database setup and storage of encrypted passwords.', 'Functions to get user by ID and username are implemented, providing efficient ways to retrieve user information. Functions to get user by ID and username are implemented, providing efficient ways to retrieve user information.', 'The process of registering a new user with an encrypted password is explained, ensuring secure storage of user credentials. The process of registering a new user with an encrypted password is explained, ensuring secure storage of user credentials.']}], 'duration': 869.665, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/1ZeDy2QI3OE/pics/1ZeDy2QI3OE52486.jpg', 'highlights': ['The chapter discusses creating a user model with fields like name, password, email, and username, using Mongoose and bcrypt for encryption.', 'Functions to get user by ID and username are implemented, providing efficient ways to retrieve user information.', 'The process of registering a new user with an encrypted password is explained, ensuring secure storage of user credentials.', 'The system is more flexible than traditional databases like MySQL, allowing for easier database setup and storage of encrypted passwords.']}], 'highlights': ['Creating a user model with fields like name, password, email, and username, using Mongoose and bcrypt for encryption.', 'Functions to get user by ID and username are implemented, providing efficient ways to retrieve user information.', 'The process of registering a new user with an encrypted password is explained, ensuring secure storage of user credentials.', 'The chapter covers setting up an express server and connecting to a MongoDB database.', 'Configuring middleware for dependencies such as cores and body parser is discussed.']}