1 00:00:00,330 --> 00:00:06,840 Right, so if you're still here, then congratulations on completing this very basic WhatsApp or I message. 2 00:00:07,980 --> 00:00:14,370 Now, there are a couple of tasks that I would like you to attempt, and they range from quick and easy 3 00:00:14,370 --> 00:00:17,750 to very difficult and might take you a very long time. 4 00:00:18,510 --> 00:00:19,290 Feel free to. 5 00:00:19,290 --> 00:00:21,480 Do you know, the first couple of them? 6 00:00:21,480 --> 00:00:22,140 Definitely. 7 00:00:22,290 --> 00:00:24,060 But after that, totally optional. 8 00:00:24,060 --> 00:00:29,760 If you want to do them, if you do do all of the tasks, then your understanding of this will improve 9 00:00:29,760 --> 00:00:35,790 no end, including if you want to do things for clients, you'll better understand the amount of work 10 00:00:35,790 --> 00:00:39,790 that goes into what you're doing so you can charge the clients accordingly. 11 00:00:39,930 --> 00:00:42,240 That's a big problem I see with new developers. 12 00:00:43,470 --> 00:00:43,850 Right? 13 00:00:43,860 --> 00:00:48,380 Your first task is when you first load the app, it allows you to log in or register. 14 00:00:48,960 --> 00:00:57,090 The problem is in our code we check the user, but no matter what that result is, we immediately set 15 00:00:57,090 --> 00:00:57,930 up Firebase. 16 00:00:58,830 --> 00:01:04,590 At the moment, that's not a problem because we don't have any rules on our database. 17 00:01:04,590 --> 00:01:07,800 We're allowing everyone to read and write to our database. 18 00:01:08,190 --> 00:01:10,980 Obviously, in production, you would never, ever do that. 19 00:01:11,250 --> 00:01:13,410 You would make sure a user is authenticated. 20 00:01:13,710 --> 00:01:20,160 So what you need to do is check the current user is true or false, and then depending on whether it's 21 00:01:20,160 --> 00:01:26,010 true or false, you actually want to then go ahead and set up Firebase, but only do it once. 22 00:01:26,280 --> 00:01:31,800 Because if you have something that checks continuously or checks every time the view loads as it comes 23 00:01:31,800 --> 00:01:38,130 onto the screen or not, that's a view will appear, then this is going to be repeated and you're going 24 00:01:38,130 --> 00:01:44,220 to get more handles, which means every time data changes, it will get added two or three times to 25 00:01:44,250 --> 00:01:45,090 your list. 26 00:01:45,450 --> 00:01:49,920 So you're going to multiply a whole bunch of bugs and problems. 27 00:01:50,670 --> 00:01:51,800 Clearly you don't want that. 28 00:01:52,080 --> 00:01:56,850 So you need to think very carefully about how you go about modifying that. 29 00:01:57,060 --> 00:02:01,860 That's your first task and that's the one I would definitely recommend you actually do. 30 00:02:01,860 --> 00:02:05,970 Do not skip it because it helps train your logical brain for this. 31 00:02:06,990 --> 00:02:18,120 The next task, if you choose to accept, is to define the data that you are sending to Firebase with 32 00:02:18,300 --> 00:02:20,430 a user ID reference. 33 00:02:21,120 --> 00:02:27,960 So in the firebase authentication documentation, it'll tell you each user has a particular user ID. 34 00:02:28,260 --> 00:02:31,260 You can use their ID, you can use their email, whatever it is. 35 00:02:31,770 --> 00:02:39,600 But I want you to do is attach a user's email to the data as it gets stored in Firebase. 36 00:02:40,080 --> 00:02:46,260 There is a way to do that and you can do that on the firebase side, not the app side. 37 00:02:47,010 --> 00:02:54,540 Never do things like that on the app side because any malicious user could add an email address and 38 00:02:54,540 --> 00:02:57,780 then they'd have access to so and so's data. 39 00:02:58,140 --> 00:03:01,500 OK, well, actually now I've messed that up a bit. 40 00:03:02,520 --> 00:03:04,320 I've been thinking too much sun. 41 00:03:04,320 --> 00:03:05,370 Let me off guys. 42 00:03:06,060 --> 00:03:13,350 What I mean to say is there is a way in Firebase or for you in Firebase Database to add the user I.D. 43 00:03:14,010 --> 00:03:17,490 that created the data to go and look at the documentation. 44 00:03:18,300 --> 00:03:21,150 And I want you to try and add the user ID to it. 45 00:03:21,630 --> 00:03:31,050 And then within the application itself, I want you to limit the messages a user can access to those 46 00:03:31,050 --> 00:03:34,560 with his own ID, i.e. the ones that he wrote. 47 00:03:35,550 --> 00:03:40,890 Now, this is a very, very difficult task if you are a new programmer, very, very difficult. 48 00:03:41,310 --> 00:03:48,390 But your starting point is the firebase documentation and looking around inserting or accessing data 49 00:03:48,570 --> 00:03:54,450 via user ID, that will give you a lot of the answers that you're looking for. 50 00:03:54,660 --> 00:04:01,650 And once you've got those answers, you will then need to modify this very slightly, probably very 51 00:04:01,650 --> 00:04:08,280 slightly, to include the current user ID and return that user IDS data. 52 00:04:08,900 --> 00:04:11,400 OK, so that's the very difficult task. 53 00:04:11,400 --> 00:04:17,580 I'm not going to give you solutions to either of these tasks because I think that good developers are 54 00:04:17,580 --> 00:04:23,730 born from create from solving hard tasks that you don't have the solutions for. 55 00:04:24,090 --> 00:04:27,890 That is basically what we have to do every single day. 56 00:04:28,140 --> 00:04:30,390 So you might as well get started now.