Well come back in the next few lessons we're going to had user authentication into camp.
So we're going to take everything we learned in the last few lessons where we did the auth demo with
the secret page and we're going to take that and apply it to camp.
And it will be broken into a few steps.
The first one is to add the user model and then also to install all of those packages that we needed
.
Let's get started.
I mean instead of V-6 now I made a new version because we are going to make some substantial changes
here.
And the first thing I'll do is just run an NPM install and install all those packages we need.
So we need passport passport dasht local and passport Dasch local Dasch mongoose and then we also need
express Dasch session and then we'll do dash dash save and we already have Express we already have body
parts or so we should be good to go.
Let's just double check on our package that.
Make sure it has all those packages good Rigaud everything looks good.
OK let's open up abdicates And let's begin by importing some of those different packages.
So we'll import.
Passport is equal to require passport and then we have a local strategy.
Require passport Dasch local and are safe there.
Now let's go about creating our user model which will require here so we can actually start with that
user.
The schools require that slash models slash user which of course will crash right now if we try and
run this.
So let's make the user model so that needs to go inside that model's directory right here we want to
make a file.
Models slash user.
Yes.
And let's open that file.
And then inside of there we're going to add in our basic mongoose code.
So the first thing you want to do is require mongoose.
OK.
And then we need our user schema and remember that our user needs to have a username and password and
both are strings
already.
So instead of here username is a string comma password is also a string.
And then at the very bottom we'll do our module.
Exports equals mongoose top model user Cingular and then the schema to construct it from.
And that's everything we need to do to make a simple user model.
It has no off yet it doesn't have passport plugged in or the passport local mongoose plug in yet.
But let's try to just make sure that this requires working and if we do that now.
Node Yes.
Everything looks good.
Stop the server.
Now let's go and add in the passport local plug in.
So we need to require that here our passport local mongoose equals require passport dash local dash
Mangus which is that package we installed.
And then we just need to do user schema plug in passport local mongoose and save and that's it.
And again that makes it really easy for us.
This basically takes the wheel and it starts to add in some methods to our user.
Now let's test this out.
It's just run the same code node app.
Yes.
Everything works just fine.
Once again good to see.
Great.
So we now have installed all the packages and we've set up the user model and added in the passport
local mongoose plugin which gives all these methods and important functionality to our user model.
And that's all I wanted to do in this video in the next video will actually start working and the functionality