Right, so here I am in the main view controller and I've just added a little bit of code here, which
constitutes the function to log out, and I did that just to check the authentication, because I discovered
that even if you delete the app and then you reloaded, I guess it has the same app identifier and device
identifier.
Therefore, Firebase just keeps it logged in.
So, you know, that's quite a seamless user user experience, isn't it?
You delete an app and then you come back and you've still got your login details and you're still logged
in just pretty handy.
So to log out what I did was this auth function or sign out, and that's to do with Firebase.
This can give an error.
So we have to put it in this special structure called a Dukat.
And inside of there, we're going to try that.
And what that means is if it throws an error, which it will if there is one, then we are going to
catch that error here and we can do something accordingly.
We don't actually have to do anything at this point because we're not letting the user we're not telling
the user, not giving the user an option to log out.
It's just for our own internal use at the moment.
Right.
So that's how they log out and that's how we get back to this point where we can see that the login
screen and if we tap stuff, everything's too short, etc..
Right.
So what are we going to do?
We're going to go to auth view controller and we are going to look at the create user section.
So we've created the user.
And if the error is not equal to now, we're going to tell them what the error is.
Otherwise, it's clear that the user has been created.
So what we can do is call self-taught Dismas on The View controller and we'll have a nice animation
to go with it.
And on completion, we will do nothing.
OK, so at this point we know we're logged in.
We'll have a nice animation to log back to go to the previous screen.
OK, we don't want the user to have to press back.
We just want it to happen seamlessly.
Right, so I'm going to put in another random email address and a random password, and then I'm going
to click register.
And we're in now, it's up to you if you want to show the user that they are logged in, that the registration
was successful, sometimes it's I find it's not actually that necessary by mere virtue of the fact that
they can access the screen where they can type messages, eventually, they will then know that they're
logged in.
So I think that part of the registration is pretty much done now.
We need to look at the login section because we've created some users.
We need to see how we log them in.
So we want to get, again, our email and password.
And I shouldn't be copying this, but I did it, so don't tell anyone.
We can always get that from a different function if we wish later on.
So let's look at how we lock in a user.
Let's see if we have a login.
No, we don't.
Do we have a sign in?
Yes, we do.
So we want a sign in.
That's an email with the email, link with email, password and completion.
That's the one we want.
So with email, of course, his email and password is the same.
And then on completion, we should get some sort of result.
What is that code?
I assume it's going to be the same as the registration.
Let's see if we get an error.
And if we don't, that should be it.
OK, so we're logged in, what do we want to do at that point we want to dismiss.
So what I'm actually going to do is down here somewhere, I'm going to cut this code to dismiss the
controller.
And I'm just going to because dismisses a taken Keywood, we know what actually we can just have dismiss.
We don't have to have self dismiss and we can just copy that.
This one I don't mind copying because this hasn't changed since forever.
So if we've signed in, then we're all good.
Now it insists on having self, I should have known that, and it wants self because we're actually
enclosed in this anonymous function and if we don't have self, we're going to have an error, as you
can see.
OK, what we do need is to also copy over this section to the login.
So we're going to show an alert error and then just give the localized description, OK, so now if
we run that, we should lock out the current user when it first loads and then we'll try to log in first
with something that doesn't actually exist yet.
So whatever at whatever dot com would be nice if I put an ad in there and then whatever password.
So login, there's no need to record correspondence, identify the user may have been deleted.
Wow, that's real friendly.
OK, what if we register this user and I'm just going to give this a password of the word password and
I'm going to copy that.
It's going to register them and we're in.
OK, now I'm going to run the app again.
It's going to log that user out and ask them to login.
So we're going to use that same user.
Log-in.
And there we go, we are in.
OK, so that's pretty much the end of this little section.
But I would say if you want to really snazzy up this and I think we will do this actually, because
you should be pretty advanced now to the point where we actually want to build nice user interfaces
for users.
So what we're going to do in the next section is change the login and register buttons to be disabled
or change them to a spinner or something like that.
So the user can't access anything.