1 00:00:00,480 --> 00:00:06,690 We can actually get on now with registering a user in Firebase, so we're in our register tapped in 2 00:00:06,690 --> 00:00:07,780 the off view controller. 3 00:00:08,070 --> 00:00:12,810 What we're going to do in here is just first of all, grab the email and the password. 4 00:00:13,530 --> 00:00:18,180 So we're going to get email, input, text, and we know it's going to be there so we can just force 5 00:00:18,180 --> 00:00:23,370 unwrap that and let the password equal the password input text. 6 00:00:23,790 --> 00:00:25,160 Same job there. 7 00:00:25,530 --> 00:00:29,460 Now, later on, we're going to ask the user to confirm their password. 8 00:00:29,730 --> 00:00:33,510 But at this point, it's a good idea just to get the basics down. 9 00:00:33,510 --> 00:00:35,730 So just register someone with a password. 10 00:00:35,730 --> 00:00:37,320 Don't check it at first. 11 00:00:37,770 --> 00:00:41,420 Don't check that the user has entered the password they thought they entered is what I mean. 12 00:00:42,030 --> 00:00:44,030 OK, so we can add that in later. 13 00:00:44,280 --> 00:00:44,970 Good to start. 14 00:00:44,970 --> 00:00:45,400 Simple. 15 00:00:46,140 --> 00:00:54,300 So now we're going to go and look at our Orff dot off and this is the object for our firebase app. 16 00:00:54,510 --> 00:01:02,990 And so I've imported up here Firebase Auth, OK, and then what we're going to do is just at the period 17 00:01:03,000 --> 00:01:04,950 key and see what comes up. 18 00:01:04,950 --> 00:01:10,260 If I start to type register now how about create and there we have it. 19 00:01:10,270 --> 00:01:13,980 So we have a create user with email and password. 20 00:01:14,700 --> 00:01:17,190 So the email address of course is what we're going to give it. 21 00:01:17,670 --> 00:01:24,790 The password is the password and on completion we are going to do something with that person. 22 00:01:25,170 --> 00:01:29,250 Now let me just look at my other code here and what did we have here? 23 00:01:29,550 --> 00:01:34,470 So on the completion object, we have a user and an error that appears. 24 00:01:34,680 --> 00:01:37,740 OK, so the error, of course, will be nil. 25 00:01:40,460 --> 00:01:46,550 If there is no error, otherwise, we have to tell the user that there is an error. 26 00:01:46,940 --> 00:01:54,230 So if the error is equal, is not equal to nil, I think I've got this right. 27 00:01:54,530 --> 00:01:59,330 Then we can tell the user through our utilities dot show alert. 28 00:02:03,030 --> 00:02:11,610 Error and the message in this particular case, we can probably grab from the firebase error as a localized 29 00:02:11,610 --> 00:02:14,700 description, I think that should be all right. 30 00:02:16,200 --> 00:02:18,800 This is optional, I believe. 31 00:02:18,810 --> 00:02:21,960 So we're going to have to. 32 00:02:25,450 --> 00:02:31,360 Let message equal to, you know what, I'm just going to remove that and I'm just going to force unwrap 33 00:02:31,360 --> 00:02:33,220 this for expediency right now. 34 00:02:33,700 --> 00:02:36,040 And the view controller, of course, is self. 35 00:02:38,590 --> 00:02:44,560 OK, so if that doesn't work, then we'll do The View controller so we can actually test that. 36 00:02:47,300 --> 00:02:52,370 And I suspect that if it doesn't work, you can see myself control there, I, I was going on YouTube 37 00:02:52,370 --> 00:02:56,180 a bit too much and I was like, come on, I need to finish these tutorials anyway. 38 00:02:57,450 --> 00:03:02,110 So if we put in the wrong email address, Firebase itself should give us an error. 39 00:03:02,130 --> 00:03:06,870 Obviously, that's not an email and obviously that is a password. 40 00:03:07,050 --> 00:03:08,250 But if I hit register. 41 00:03:09,190 --> 00:03:13,960 The email address is badly formatted, so Firebase will take care of all of that for us. 42 00:03:13,960 --> 00:03:24,880 So I put an atin still badly formatted, OK, if I do whatever at whatever dot com, now I try to register. 43 00:03:26,490 --> 00:03:33,420 We should be registered, so if I load this app up again, we have logged in via that registration link 44 00:03:33,420 --> 00:03:36,640 already and we won't get that screen shown. 45 00:03:36,990 --> 00:03:39,360 Obviously, we have no way to log out at this point. 46 00:03:39,660 --> 00:03:46,760 The only way to effectively log out right now is to remove the app, delete all of its data, because 47 00:03:46,940 --> 00:03:50,100 the next time we load it, we will get that registration screen. 48 00:03:50,850 --> 00:03:57,810 OK, so we've created the user now and we can actually go over to our firebase console and have a look 49 00:03:57,810 --> 00:03:58,970 at that particular user. 50 00:03:59,280 --> 00:04:03,210 This still thinks it's logged in for some reason, so I'll fix that outside of this. 51 00:04:03,210 --> 00:04:05,480 But let's go look at the firebase console. 52 00:04:06,450 --> 00:04:09,330 So here we are in our firebase item. 53 00:04:09,330 --> 00:04:11,070 Let's Firebase Project. 54 00:04:11,070 --> 00:04:13,920 Let's go to the authentication on the left hand menu. 55 00:04:14,610 --> 00:04:19,020 And there you'll see we have our user that we created with its fake email address. 56 00:04:19,390 --> 00:04:22,110 It has a user I.D. that gets attached to that. 57 00:04:22,380 --> 00:04:23,710 We can reset their password. 58 00:04:23,730 --> 00:04:25,740 We can disable or delete their account. 59 00:04:25,980 --> 00:04:28,950 And it tells us their provider is only email. 60 00:04:29,310 --> 00:04:34,590 If they had used a Google login, a Facebook login, an Apple login, then we would get the provider's 61 00:04:34,980 --> 00:04:36,330 excuse me there. 62 00:04:36,840 --> 00:04:39,460 OK, so that tells us what we need to know. 63 00:04:39,930 --> 00:04:47,220 Usage hasn't actually increased to one user, but whatever, that will probably catch up over time. 64 00:04:47,730 --> 00:04:49,680 OK, so that's the authentication. 65 00:04:49,680 --> 00:04:50,790 That's the registration. 66 00:04:51,010 --> 00:04:58,980 Now we need to look at fixing up the whole app or fixing up the authentication area so it's much more 67 00:04:58,980 --> 00:04:59,850 user friendly.