Join Alexander Zanfir for an in-depth discussion in this video Associate a user with post when making a post, part of MEAN Stack and MongoDB: Development Techniques.
- [Voiceover] Now that we are authenticating the user,…we can focus on associating the user with a message post…so we know who posted the message.…In order to do that, we'll need to get the user ID…from the user who posted the message.…And since we are using Satellizer,…it will attach our token in the header…of every request we send to our server.…So our Node app now just needs to grab the user ID…from the token we receive in the header.…Let's go ahead and implement that now.…We will create a new middler function…and call it checkAuthenticated.…
And since it's a middler function,…it will need a request, response and next.…Now since Satellizer passes the token in the header,…we need to check if the header…contains an authorization object.…If it does not, let's return a 401 with a custom message.…Next let's extract the token by getting the second element…in the authorization header after splitting it.…Now just like we encoded our token, let's decode it,…and we'll use the same secret we used before.…But once again, if this was in production,…
- Installing and setting up your MEAN toolset
- Making an Angular post form
- Sending posts
- Displaying messages
- Creating a registration form
- Saving users
- Associating users with posts
- Authenticating users at login
Skill Level Intermediate
2. Message Posting
3. Display Messages
Save a user with Mongo13m 26s
5. Logging In
Next steps2m 5s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.