Welcome back.
Now, the next thing we want to do is we want to sign in the user now you might say, hey, we have
signed a new user already, so why would we do it again?
What is the purpose of this?
Well, we signed in the user.
Yes, but we didn't get to data about the user yet as we didn't have the data before.
Now, in the last video, we added to data about the user and we want to store additional information
about, for example, the boards that the user is assigned to or has created with all of the different
tasks that he has to do and so forth.
So in order to implement that, we need to create a new function in our five store class.
So we have this function called registered user.
Now let's go ahead and create one which is going to sign in the user.
All right.
Fun sign in user.
And we need to have the activity.
So it's not the sign up activity is the sign in activity that we need because we actually want to execute
some code from the sign in activity.
So let's go ahead.
Now, the thing is, we're going to use a similar approach then or as we have done with registering
the user, the difference is that we don't want to set something.
We want to get something.
So let's just copy this code that we had here and I'm going to go over it real quick.
So we need to fire store again.
We need to access the collection.
Constance users.
We want to get document that is assigned to the user that is currently locked in soccer and user I.D.
But then instead of setting something, we want to get something and we don't need to pass in any additional
information.
We just want to get something.
All right.
And here.
Let's just get rid of those entries for now, so here, instead of just displaying or instead of doing
what we did before in our registering class where we used to registered success, we will do the same
thing with Log-in success.
OK, but in order to do so, first of all, I'm going to prepare this by having a new variable which
is going to store water logged in user because I want to know more about it.
And the thing is, our document gets us this information.
So the document has all of the information that the current user ID.
So here I want to use this document and.
Make an object of it to object.
Now, the document from here, in order to get it, what we need to add is a little lambda expression.
All right, so here we just say, OK, document.
Give me the argument, and once I have it, I want to make an object of it.
Now, when you use the two object method, you also need to say of which class you want to use the object
method.
And I want to use it for this user.
So I want to make a user object out of whatever is given to me in the document.
All right.
So here I can just say, OK, make a user out of this.
OK, so this is going to give me the logged in user.
Now let's look at it in the database.
So in the database, it will be this user here.
Which is why Cucu H, m and so forth.
All right, so this is going to be the user object that I want to have.
This is the you you ID that I just got from the get current user function.
And then these are all of the information for that object.
So here.
Now, I have the logged in user, now I know about him, I have his address.
Well, he didn't stories that was a part of his e-mail address, have his name and so forth.
All right.
So now I can sign in that user.
And what I'm going to do is I'm going to call activity DOT sign in success and Canopus and they're locked
in user.
Now, you might wonder what is the sign and success function?
Well, we still need to create it.
So inside of the activity that is passed to us when we sign in and it's in the sign in activity.
So let's go ahead and create a new function here.
Which is going to be called sign and success, so fun sign and success.
It's going to be a new function here.
Which needs a user object, so we're going to pass the user to it.
All right, now let's import user here, and we're talking about our own user, not the firebase user.
So the user that we created from our model and here highlight progress dialog.
So first of all, when we are signed, then we want to highlight the progress dialogue and then we want
to start an activity which is going to send us to the main activity so similar to what we did when we
registered.
So here, just part here.
OK, let's do that.
So start activity, intent from this activity to the main activity and then also let's finish the current
activity so that the user can't get back to this log in or sign in activity anymore.
So this is called sign and success, and this is, of course, also only going to be called when we
actually have a successful listener here or if we had success when getting the collection of the user
with the current user ID.
All right, so we pass in the logged in user.
And it could be now.
That's what it's saying here, and we can Forestier or we can add a check.
So if you really wanted to make sure that it's of the right type, if you want to make sure that it's
actually not going to be null, you could add something like if logged in user, not equal.
Now, then execute this code here.
All right.
So then it's still complaining here in the ad on Failure Listener, because it doesn't like my activity
that I'm passing here.
So let me just say something like fire or class sign in a user.
And that's a long or too long name.
But still too long, fast.
Well, let's just say signing user.
And now we can go ahead and test our application.
All right, Sinon.
It was Dennis hatchetman, God comment on.
The password.
And we're.
Transferred to the main activity.
All right, so this seems to work as well.
All right, now we are locked in and we have the user information.
We could display the user information here and we could add a settings screen, which we will do later
on and a lot more.
All right.
So let's go ahead and do some more stuff in the next video.
See you there.