We can actually get on now with registering a user in Firebase, so we're in our register tapped in
the off view controller.
What we're going to do in here is just first of all, grab the email and the password.
So we're going to get email, input, text, and we know it's going to be there so we can just force
unwrap that and let the password equal the password input text.
Same job there.
Now, later on, we're going to ask the user to confirm their password.
But at this point, it's a good idea just to get the basics down.
So just register someone with a password.
Don't check it at first.
Don't check that the user has entered the password they thought they entered is what I mean.
OK, so we can add that in later.
Good to start.
Simple.
So now we're going to go and look at our Orff dot off and this is the object for our firebase app.
And so I've imported up here Firebase Auth, OK, and then what we're going to do is just at the period
key and see what comes up.
If I start to type register now how about create and there we have it.
So we have a create user with email and password.
So the email address of course is what we're going to give it.
The password is the password and on completion we are going to do something with that person.
Now let me just look at my other code here and what did we have here?
So on the completion object, we have a user and an error that appears.
OK, so the error, of course, will be nil.
If there is no error, otherwise, we have to tell the user that there is an error.
So if the error is equal, is not equal to nil, I think I've got this right.
Then we can tell the user through our utilities dot show alert.
Error and the message in this particular case, we can probably grab from the firebase error as a localized
description, I think that should be all right.
This is optional, I believe.
So we're going to have to.
Let message equal to, you know what, I'm just going to remove that and I'm just going to force unwrap
this for expediency right now.
And the view controller, of course, is self.
OK, so if that doesn't work, then we'll do The View controller so we can actually test that.
And I suspect that if it doesn't work, you can see myself control there, I, I was going on YouTube
a bit too much and I was like, come on, I need to finish these tutorials anyway.
So if we put in the wrong email address, Firebase itself should give us an error.
Obviously, that's not an email and obviously that is a password.
But if I hit register.
The email address is badly formatted, so Firebase will take care of all of that for us.
So I put an atin still badly formatted, OK, if I do whatever at whatever dot com, now I try to register.
We should be registered, so if I load this app up again, we have logged in via that registration link
already and we won't get that screen shown.
Obviously, we have no way to log out at this point.
The only way to effectively log out right now is to remove the app, delete all of its data, because
the next time we load it, we will get that registration screen.
OK, so we've created the user now and we can actually go over to our firebase console and have a look
at that particular user.
This still thinks it's logged in for some reason, so I'll fix that outside of this.
But let's go look at the firebase console.
So here we are in our firebase item.
Let's Firebase Project.
Let's go to the authentication on the left hand menu.
And there you'll see we have our user that we created with its fake email address.
It has a user I.D. that gets attached to that.
We can reset their password.
We can disable or delete their account.
And it tells us their provider is only email.
If they had used a Google login, a Facebook login, an Apple login, then we would get the provider's
excuse me there.
OK, so that tells us what we need to know.
Usage hasn't actually increased to one user, but whatever, that will probably catch up over time.
OK, so that's the authentication.
That's the registration.
Now we need to look at fixing up the whole app or fixing up the authentication area so it's much more
user friendly.