1 00:00:00,009 --> 00:00:01,470 Welcome back. 2 00:00:01,480 --> 00:00:07,190 So now we're gonna create the function that will display the post login menu 3 00:00:07,550 --> 00:00:10,970 for our logged in users with options. So 4 00:00:11,260 --> 00:00:18,069 let us do that just above the function to view the logs. So right here, 5 00:00:18,930 --> 00:00:24,670 I'm gonna say a function to display 6 00:00:26,010 --> 00:00:28,469 post login menu. 7 00:00:28,870 --> 00:00:29,520 OK? 8 00:00:29,680 --> 00:00:31,030 All right. So as usual, 9 00:00:31,299 --> 00:00:36,970 we're going to call this one, let's say post underscore login underscore menu. 10 00:00:37,729 --> 00:00:39,389 I think that's a good name. 11 00:00:39,750 --> 00:00:44,439 And of course, inside we're gonna pass in a parameter, username at a colon. 12 00:00:44,819 --> 00:00:46,150 OK? So 13 00:00:46,540 --> 00:00:49,909 we're gonna create a while statement. So while 14 00:00:50,069 --> 00:00:52,439 the user is in fact logged in, 15 00:00:52,650 --> 00:00:54,549 let us now print out the 16 00:00:54,720 --> 00:00:56,150 options for them. 17 00:00:56,909 --> 00:00:58,970 So first of all, I'm actually gonna print out 18 00:00:59,409 --> 00:01:04,949 like a regular uh message. So I can say something like uh log in 19 00:01:05,730 --> 00:01:11,989 uh I'm sorry, post login menu, right? Post dash login menu. 20 00:01:13,010 --> 00:01:14,669 OK? And let me add my 21 00:01:15,680 --> 00:01:18,419 backward slash N so that this is on a new line. 22 00:01:18,949 --> 00:01:23,739 And OK. So now we can print out the options. There's only going to be two of them. 23 00:01:24,519 --> 00:01:28,980 OK? So option number one will be to simply view 24 00:01:30,040 --> 00:01:30,059 uh 25 00:01:30,169 --> 00:01:34,819 my logs. Remember this is personalized it's for the logged in user. 26 00:01:35,580 --> 00:01:38,510 And then option number two, well, 27 00:01:38,959 --> 00:01:40,199 log out, I guess. 28 00:01:41,610 --> 00:01:43,690 And there it is. So 29 00:01:44,349 --> 00:01:47,870 we're gonna have to ask the user which option they want to go for. So 30 00:01:48,080 --> 00:01:50,830 I'm gonna say choice equals and then input 31 00:01:51,209 --> 00:01:55,239 and then we can say something like uh you know, what would 32 00:01:55,480 --> 00:01:57,209 you like to do? 33 00:01:57,480 --> 00:01:58,610 Question mark? 34 00:01:59,250 --> 00:01:59,949 OK. 35 00:02:00,150 --> 00:02:04,430 So now we're gonna have to create the el statements for each scenario. So 36 00:02:04,889 --> 00:02:07,739 I'm gonna go with the first one. If 37 00:02:08,869 --> 00:02:12,139 uh if choice equals one, 38 00:02:12,449 --> 00:02:15,039 what they wanna do, wanna view the logs 39 00:02:15,229 --> 00:02:18,820 and of course, the username. So we're gonna call in the function which is view logs, 40 00:02:18,990 --> 00:02:21,539 user name. So very, very simple. 41 00:02:21,649 --> 00:02:24,970 And then we can say L if choice 42 00:02:26,460 --> 00:02:27,639 uh equals 43 00:02:28,429 --> 00:02:29,210 uh 44 00:02:29,399 --> 00:02:30,289 two 45 00:02:30,539 --> 00:02:32,949 and then what do we want to do in here? 46 00:02:33,240 --> 00:02:35,169 Well, we can simply print out 47 00:02:36,399 --> 00:02:37,479 a message 48 00:02:39,070 --> 00:02:40,979 that says logged 49 00:02:41,110 --> 00:02:43,199 out successfully. 50 00:02:43,619 --> 00:02:46,580 But then don't forget we want to log every 51 00:02:47,009 --> 00:02:49,479 uh every task. So 52 00:02:49,860 --> 00:02:52,539 we're gonna add the log event 53 00:02:53,199 --> 00:02:54,380 statement in here. 54 00:02:54,630 --> 00:02:56,059 So log events 55 00:02:56,580 --> 00:02:58,820 and then we can say something like uh 56 00:02:59,830 --> 00:03:00,600 if 57 00:03:01,639 --> 00:03:02,940 F string and then 58 00:03:03,339 --> 00:03:04,820 we can say user, 59 00:03:05,759 --> 00:03:07,449 I have a collie braces 60 00:03:08,470 --> 00:03:13,139 in single codes, user username, uh logged out 61 00:03:13,800 --> 00:03:15,440 and there you go. 62 00:03:15,449 --> 00:03:15,869 And of course, 63 00:03:15,880 --> 00:03:19,300 don't forget we need the break set mentioned in case the logged in user decides to, 64 00:03:19,309 --> 00:03:20,149 for some reason, 65 00:03:20,309 --> 00:03:23,910 choose option 34 or five or any other option that doesn't exist So 66 00:03:24,110 --> 00:03:27,199 we're gonna say break. And then else 67 00:03:27,889 --> 00:03:30,869 you can just simply print out a message that says 68 00:03:32,020 --> 00:03:37,710 uh invalid choice. Please try again. 69 00:03:37,880 --> 00:03:38,490 And 70 00:03:39,050 --> 00:03:41,119 there it is. OK. So 71 00:03:41,270 --> 00:03:47,110 we have successfully now created the functional display the post login menu. 72 00:03:47,330 --> 00:03:48,449 However, 73 00:03:48,589 --> 00:03:55,039 how do we actually link it to the login function? Because once the user logs in, 74 00:03:55,350 --> 00:03:58,279 we want to call this function. So 75 00:03:58,449 --> 00:04:02,460 what do we do? We're gonna go over to the main login function. 76 00:04:02,759 --> 00:04:05,770 And now let's look at the code where has the user logged in? 77 00:04:05,779 --> 00:04:08,490 It says right here login successful. 78 00:04:08,729 --> 00:04:13,210 So right here where it says the login successful, 79 00:04:13,360 --> 00:04:17,450 I'm gonna come over here right now and now call our function. 80 00:04:17,459 --> 00:04:19,309 So here I'm going to say post 81 00:04:19,619 --> 00:04:22,920 underscore login underscore menu 82 00:04:23,140 --> 00:04:25,989 and of course, in brackets, we're going to add the username 83 00:04:26,950 --> 00:04:27,609 and 84 00:04:27,890 --> 00:04:30,329 there you go. So 85 00:04:31,739 --> 00:04:37,320 that's it. I think we have successfully finished writing our code. 86 00:04:37,589 --> 00:04:39,600 Let's now test it out. 87 00:04:40,220 --> 00:04:41,640 I'm gonna run the code. 88 00:04:42,010 --> 00:04:42,630 OK? 89 00:04:43,579 --> 00:04:49,920 And I am going to log in first of all as actually, you know what, 90 00:04:51,579 --> 00:04:54,760 I'm going to try something else. OK? I'm just register 91 00:04:54,940 --> 00:04:55,679 a new user. 92 00:04:56,470 --> 00:05:01,429 Ok? And I'm going to call this user Boris. OK? And then password will be Boris 93 00:05:01,899 --> 00:05:04,799 123 with the at symbol. 94 00:05:05,540 --> 00:05:06,209 OK? 95 00:05:06,459 --> 00:05:08,299 So now let Boris 96 00:05:08,570 --> 00:05:11,320 log in. So Boris and then 97 00:05:11,980 --> 00:05:14,040 bodies 123, 98 00:05:14,320 --> 00:05:15,829 the add symbol 99 00:05:15,989 --> 00:05:20,320 and there you go. Yes, we can see bodies. Now has the post login menu 100 00:05:20,549 --> 00:05:23,459 and can bodies view his logs. We're gonna press one 101 00:05:23,890 --> 00:05:29,660 and there you go logs for user bodies bodies successfully registered at 835. 102 00:05:29,760 --> 00:05:33,579 And then he's successfully logged in at 8 1045. 103 00:05:33,839 --> 00:05:36,890 And if we look at our users dot TXT, there you go. We have bodies 104 00:05:37,179 --> 00:05:38,720 with his hash password. 105 00:05:39,010 --> 00:05:40,790 And then over here we have the 106 00:05:40,799 --> 00:05:45,190 Alex successfully registered John successfully logged in. 107 00:05:45,200 --> 00:05:46,170 Obviously, these are 108 00:05:46,429 --> 00:05:48,309 tests that I did off screen. 109 00:05:48,480 --> 00:05:52,470 But you can see right now that the program is in fact working successfully. 110 00:05:52,790 --> 00:05:55,859 There are a few other tests we can run. We can make sure 111 00:05:56,600 --> 00:05:59,459 that if I typed in option number five in here, 112 00:06:00,320 --> 00:06:01,010 ok, 113 00:06:01,179 --> 00:06:03,220 I typed in five and I pressed enter, 114 00:06:03,480 --> 00:06:06,739 it can say invalid choice. Please try again. 115 00:06:07,450 --> 00:06:09,709 So let me try to log out now 116 00:06:09,980 --> 00:06:11,250 and you can see it in fact 117 00:06:11,500 --> 00:06:12,880 successfully logged out. 118 00:06:13,010 --> 00:06:14,350 And if I press three 119 00:06:15,290 --> 00:06:16,459 at the main menu, 120 00:06:16,600 --> 00:06:18,239 you can see right now it has exited the 121 00:06:18,250 --> 00:06:23,160 system and our program is in fact working properly. 122 00:06:23,170 --> 00:06:23,709 So 123 00:06:24,130 --> 00:06:25,570 there it is. Congratulations. 124 00:06:25,579 --> 00:06:30,720 You have successfully created a pretty advanced user registration system 125 00:06:31,100 --> 00:06:33,290 that would allow users to register. 126 00:06:33,299 --> 00:06:36,679 We've also implemented a password checker to ensure 127 00:06:37,019 --> 00:06:40,850 that the password is strong enough by having at least eight characters long, 128 00:06:41,000 --> 00:06:45,200 having one uppercase letter one number and also a special symbol. 129 00:06:45,579 --> 00:06:46,079 And of course, 130 00:06:46,089 --> 00:06:48,869 we've also added additional security features to 131 00:06:48,880 --> 00:06:51,440 hash the password so that they're stored 132 00:06:51,799 --> 00:06:53,529 in a hashed format. 133 00:06:53,690 --> 00:06:54,149 And of course, 134 00:06:54,160 --> 00:06:56,649 we also created a post login menu for the logged in 135 00:06:56,660 --> 00:07:00,440 users where they can then view their own personal logs. 136 00:07:00,910 --> 00:07:03,230 That's it. It's been fun. Thank you so much for watching. 137 00:07:03,239 --> 00:07:04,760 I will see you in the next class.