Welcome back.
In this video, let's see how authentication works.
So let's get started.
All right.
First of all, let's say that we have this particular client or user who is trying to use our application,
and definitely the user is going to use a browser in this case, Google Chrome.
So as soon as the user open our application, a form will be open to the person.
But before logging in, let's see what goes on here.
First, we need a server where the user is going to make a request to and for this particular server.
Let's say we build this server using Node.js and definitely having server alone.
We need a way to store data.
That is why we need data source.
And for this case it's going to be MongoDB.
Now we have these three things in the mix.
So now let's look at the flow.
When a user visit our URL, a form will be open for the user.
So as soon as the user enter the login credentials, let's say email and password.
The first point is that the data will be sent to our server.
Then the server will also send the request to the database to find if this particular user details is
really inside this database.
So if it founds, for example, if the username here is a and then inside the DB is A and the password
is B, and inside DB the password is B, it means that it matches.
So we are going to implement that logic inside our server where we are going to check the user data
against the data inside the database.
So once the user logging credential is wrong, then the process will exit.
So you will see what is called login failed or invalid login credentials.
In this way, the response was sent from the client to the server and server to MongoDB, and then MongoDB
will send the response back to the server.
The server response said, Hey, MongoDB says that we don't know this particular email, so you are
not authorized to log in.
But let's say that the user provides the right logging credentials.
Then the database response we give you to our server and our services that Hey, user MongoDB says that
your data are inside the database so you can go ahead and log in.
So at this point, the user has been, what, log in.
So in a nutshell, when entering your record into our server is going to check if the record the user
is trying to enter is inside our database.
If it is there, then the user will go ahead and then log in.
Otherwise, we're not return error.
So this is a basic flow and this is what we are going to implement.
So where we are going to work on is inside our server here.
All right.
So in the next video, let's get started with the low level authentication where a user is going to
log in with a plain email and then password or username.
Let's get into that in the next video.