- [Instructor] So we have managed to log in the user
with our login form, however,
other than being in this meeting's route,
we don't know that we have a user
and that they've logged in.
It'd be nicer to sort of see some visual feedback.
So what I'll do is I'll go over to app.vue
and I'm going to add something right here
to make sure that when a user logs in
that we capture that information.
And that's going to be done through
a Firebase method called auth,
and then we can say whenever
the state of the authentication has changed.
So for example,
when a user logs in or when they log out
or whenever an authentication event takes place,
then we can do something.
And what we want to do is capture some information
from the database.
I'm going to call it user
'cause that's usually the information
that we receive back from the database.
And then I'm going to make sure that that user exists,
and if that's the case,
then I will make the local variable called user
be the information that we receive from Firebase.
So we're actually going to receive a ton of information.
This is almost like an event.
It has a lot of information about the user.
And we'll just go ahead and capture the user email,
'cause that's what we're interested in.
So right now there isn't a name that we've asked for.
We'll do that whenever we create a new user
or we register a user,
but for right now let's just capture the email
and we can get rid of all this other information here
because we're not going to be using the database.
We're just going to make sure that somebody has logged in
and that user is authenticated.
So you can see right now, then,
that my email address appears right here
and if I refresh the page,
I should still be able to see that eventually
as the user gets logged in.
So you may notice that it sometimes takes a while.
It depends on your connection.
This is what we call an asynchronous event.
It's an event that's going to happen
at some point in time,
And a lot of your application
has to be written with that in mind,
that we can't just ask for information
and assume that that information is going to be there.
We have to look for things,
like authentication state changes,
and then do something when those changes take place.