1 00:00:00,770 --> 00:00:06,320 Hey guys in this video we're actually going to start building out or manage users where we'll be retrieving 2 00:00:06,320 --> 00:00:13,970 all of the active users one allowing the user to add or at least an admin user to be able to add deactivate 3 00:00:14,060 --> 00:00:17,840 or reset the password of another user. 4 00:00:17,930 --> 00:00:24,080 And so the first thing that we want to look at however our code changes that I made between the previous 5 00:00:24,080 --> 00:00:25,250 lesson and this one. 6 00:00:25,280 --> 00:00:31,460 So one I modified my log in logic the query that is checking for our user. 7 00:00:31,730 --> 00:00:36,680 I added the constraint that the Q Dot is active must be true. 8 00:00:36,680 --> 00:00:43,580 So firstly we were looking for in the database gets all the users with the get the first user from the 9 00:00:43,580 --> 00:00:51,080 user stable that has a matching User name password in the database that matches our hashed version of 10 00:00:51,080 --> 00:00:52,550 what the rules entered. 11 00:00:52,550 --> 00:00:59,000 And then I added a third constraint where I said and the active flag must be equal into true so you 12 00:00:59,000 --> 00:01:02,390 would remember that we added is active flag. 13 00:01:02,390 --> 00:01:05,300 Now we set to boolean in the previous video. 14 00:01:05,630 --> 00:01:07,490 And so that must be true. 15 00:01:07,490 --> 00:01:14,090 So the same logic applies all three of these most much and if it doesn't then we say please provide 16 00:01:14,180 --> 00:01:15,370 valid credentials. 17 00:01:15,380 --> 00:01:16,050 Right. 18 00:01:16,070 --> 00:01:17,720 It can be more specific than that. 19 00:01:17,720 --> 00:01:21,790 I mean you can probably get into the details as to why was. 20 00:01:21,800 --> 00:01:27,860 But like I said the more generic the better for malicious attempts on your system. 21 00:01:28,160 --> 00:01:31,710 And then I modified our code in the. 22 00:01:31,750 --> 00:01:37,730 So you take a look at this code where instead of doing all the processing to find the role name like 23 00:01:37,730 --> 00:01:41,570 we did initially and then passing just the rule name over. 24 00:01:41,570 --> 00:01:48,020 I'm actually just passing the entire user object over to the mean windows so I say Varma and Windows 25 00:01:48,020 --> 00:01:53,180 equal to man window and I'm passing this karma user. 26 00:01:53,180 --> 00:01:59,490 So when the user is retrieved I want to pass out the entire object over to the mean window. 27 00:01:59,490 --> 00:02:04,800 Now this will give me more flexibility because I'm just going to bring a will mean window. 28 00:02:04,800 --> 00:02:12,370 No I am I can use this user object to access any data but the user that I wanted including the rule. 29 00:02:12,380 --> 00:02:18,460 So initially would have used it to access the rule information and then past only the rule information. 30 00:02:18,470 --> 00:02:25,790 This I'm just passing all of the user information and then on a case by case basis we can access the 31 00:02:25,790 --> 00:02:27,830 user information if we want. 32 00:02:27,830 --> 00:02:33,620 So I introduced our new property instead of the mean window and I said public to user on the square 33 00:02:33,620 --> 00:02:34,260 user. 34 00:02:34,380 --> 00:02:37,820 This one is on the squirrel name and you can see some of them are okay. 35 00:02:37,830 --> 00:02:43,010 So one of my locus I need to be more consistent so they may change URL name to come case. 36 00:02:43,110 --> 00:02:46,010 Ah so everything looks a bit more consistent. 37 00:02:46,190 --> 00:02:53,960 And then inside of the constructor I am initializing I have my log in object I have my user object and 38 00:02:53,960 --> 00:02:59,510 I'm still just going to set the rule names separately because I don't want to repeat this bit of code 39 00:02:59,540 --> 00:03:01,400 every time I want to rule a name. 40 00:03:01,520 --> 00:03:07,150 Right now this bit of code that I just highlighted I condensed it even further. 41 00:03:07,160 --> 00:03:12,740 So the last time what we did was we got the user rules and we've got the first order defaults and then 42 00:03:12,740 --> 00:03:19,060 we add another variable where we got the rule dots shark name from the first default in this case had 43 00:03:19,060 --> 00:03:20,760 did it all out once. 44 00:03:20,760 --> 00:03:26,240 So I'm gonna show you how there are so many ways to write your queries and link that as long as it works 45 00:03:26,260 --> 00:03:30,380 its good and link is kind of designed to be as efficient as it can. 46 00:03:30,380 --> 00:03:34,730 So even here write it this way or another way it's almost going to be the same runtime. 47 00:03:34,850 --> 00:03:40,650 So you know efficiency aside there are so many ways you can write your queries. 48 00:03:40,700 --> 00:03:46,490 So in this situation I'm saying that the role name is equal to my user object which still has the list 49 00:03:46,490 --> 00:03:49,210 of user rules that we determined. 50 00:03:49,370 --> 00:03:52,540 And then I'm saying give me the first or default one. 51 00:03:52,670 --> 00:04:00,650 No once you do a first or default it is going to bring back only one instance of an object one result. 52 00:04:00,680 --> 00:04:07,290 Once I have one result I can see a dot and then call the the associated table. 53 00:04:07,310 --> 00:04:12,700 So this would be like my inner join and then call the property I want saw added scenes Get me the first 54 00:04:12,700 --> 00:04:19,160 R default user all is required for the user then look at the role and get me the details of that rule 55 00:04:20,780 --> 00:04:25,700 saying bits of code that we wrote except we split into into lines last time I'm doing it in one line 56 00:04:25,700 --> 00:04:26,610 here. 57 00:04:26,870 --> 00:04:31,090 So you know if one were one way it works for you better you can read the other one better. 58 00:04:31,100 --> 00:04:31,820 That's fine. 59 00:04:31,820 --> 00:04:38,060 You can always just copy it over and reproduce it that's no problem as long as it's works it's good. 60 00:04:38,150 --> 00:04:39,470 Everything else remains the same. 61 00:04:39,470 --> 00:04:46,480 And like I said in this video we're going to focus on our manage users screen so already kind of putting 62 00:04:46,490 --> 00:04:53,060 some groundwork on this form of managed users we have the refresh of the grid and I don't think I renamed 63 00:04:53,060 --> 00:04:56,480 the grid so let me just go over and rename it quickly. 64 00:04:56,510 --> 00:04:59,740 This should be GV user list. 65 00:04:59,920 --> 00:05:01,080 All right. 66 00:05:01,160 --> 00:05:09,080 So GV user list and then we have our different buttons one to add a new user one to reset a user's password 67 00:05:09,320 --> 00:05:11,990 and the one to deactivate the user. 68 00:05:11,990 --> 00:05:17,780 So let me just go over to the court file for Monday's users and I need to initialize something that 69 00:05:17,780 --> 00:05:22,400 will allow us to connect to the database by now we should all be familiar with the fact that we need 70 00:05:22,400 --> 00:05:30,020 our private Object or private property sorry wharf type car rental entities on the square D.B. and then 71 00:05:30,020 --> 00:05:37,130 we initialize that instead of our constructor and then we have our three object three functions sorry. 72 00:05:37,160 --> 00:05:43,220 So I'm going to deal with the easiest ones are the easy ones first and for me the easy ones would be 73 00:05:43,220 --> 00:05:49,790 the reset password and the deactivate because I don't have to do much design work as opposed to you 74 00:05:49,780 --> 00:05:54,880 know when compared to the beaten and user click because then I have to design a whole farm. 75 00:05:54,920 --> 00:06:03,020 These are simple queries so the simple query would be that when the person selects a user from the list 76 00:06:03,320 --> 00:06:09,590 then they would be able to click reset password and then I'm just going to generate a generic or have 77 00:06:09,590 --> 00:06:15,770 a generic password that is going to get hashed P replace their existing password in the database and 78 00:06:15,770 --> 00:06:19,790 then that is what they're expected to type in when it is that they're logging in. 79 00:06:19,790 --> 00:06:20,080 All right. 80 00:06:20,420 --> 00:06:26,120 So I'm going to put in the reset password functionality and like I did last time I'm just going to borrow 81 00:06:26,120 --> 00:06:31,550 some code from one of the existing manage screens right. 82 00:06:31,550 --> 00:06:39,410 So in the manage vehicle listing what I had done was I said that for B10 at its car whatever it is that 83 00:06:39,410 --> 00:06:45,260 was selected the selected rule that is the one I want to retrieve and then do my operations. 84 00:06:45,260 --> 00:06:49,670 I'm just going to literally copy all of this because it's there already. 85 00:06:49,670 --> 00:06:50,380 We wrote it. 86 00:06:50,390 --> 00:06:51,010 It's ours. 87 00:06:51,020 --> 00:06:53,920 So we can reuse it at will. 88 00:06:53,930 --> 00:07:01,990 So I went to see beat and reset buzzer click I want to retrieve from user list GV user lists. 89 00:07:02,000 --> 00:07:02,270 Right. 90 00:07:02,270 --> 00:07:08,730 So we haven't done anything to populate GV user lists just yet but GV user lists get a selected roll 91 00:07:09,050 --> 00:07:15,670 and the cells should be I.D. And let me just go back to my database and make sure that it is capital 92 00:07:15,710 --> 00:07:19,070 I.D. which it is not it is common I. 93 00:07:19,280 --> 00:07:23,020 So there again I'm being very inconsistent and that's not good. 94 00:07:23,120 --> 00:07:28,030 But you know it's good that we see these things and common mistakes so they want to be consistent in 95 00:07:28,030 --> 00:07:31,280 their cases in a database and in your code. 96 00:07:31,280 --> 00:07:37,100 All right so we're getting the value associated with the selected rule and then I'm looking inside of 97 00:07:37,100 --> 00:07:47,150 the user's table not the type of card stable so user stable Q Dot I.D. being equivalent to the idea 98 00:07:47,150 --> 00:07:56,190 that was selected and then I'm not able to launch any screen or new windows I can remove all of this. 99 00:07:56,270 --> 00:08:06,070 And then what I will see is that var password or var new on the square password is equal to. 100 00:08:06,710 --> 00:08:13,640 And then I can put in a generic one so you can probably auto generate something based on the details. 101 00:08:13,700 --> 00:08:19,070 I know some people they would do is auto generates a password based on the user details but user details 102 00:08:19,070 --> 00:08:22,990 would usually be like First Name Last Name Date of birth and such. 103 00:08:23,030 --> 00:08:27,240 I didn't call it those details I'm not storing those details of all my users. 104 00:08:27,350 --> 00:08:30,110 If you are though you can use that to your advantage. 105 00:08:30,110 --> 00:08:30,650 Right. 106 00:08:30,750 --> 00:08:34,550 But in my simple example all I have is user name and password. 107 00:08:34,610 --> 00:08:41,870 So I'm just going to put in something that says what I'm just going to put in a generic password. 108 00:08:41,870 --> 00:08:47,720 So your new password would be pass word at sign 1 2 3. 109 00:08:47,740 --> 00:08:52,370 All right to communicate with it use it at you reset the password their new password is that and then 110 00:08:52,370 --> 00:08:58,640 you could build in I did that once they put in that generic password they have to change their password. 111 00:08:58,760 --> 00:08:59,450 All right. 112 00:08:59,600 --> 00:09:03,390 So their new password is password 1 2 3. 113 00:09:03,440 --> 00:09:05,050 Then we want to hash it. 114 00:09:05,080 --> 00:09:12,110 So we're using the SHA 2 5 6 algorithm if you look back in the logging not see us file you see SHA 2 115 00:09:12,110 --> 00:09:17,360 5 6 and you'll see all of the code that we need to hash so I'm actually just going to copy and paste 116 00:09:17,360 --> 00:09:23,160 a lot of this and then you'll see that this no once it's repeating itself and it's repeating itself 117 00:09:23,220 --> 00:09:30,140 across multiple forms we could probably create one function that is called that does this job. 118 00:09:30,150 --> 00:09:32,400 So I'm actually going to do that right now. 119 00:09:32,400 --> 00:09:36,620 So inside of my solution Explorer I have a file called utilise. 120 00:09:36,660 --> 00:09:37,440 All right. 121 00:09:37,440 --> 00:09:39,060 And then in this form. 122 00:09:39,060 --> 00:09:45,420 Well in this class what I had done was I created a utility for the forum is open so I'm going to do 123 00:09:45,420 --> 00:09:56,880 another one where I'm going to see public static and this is going to return that's a string and then 124 00:09:56,880 --> 00:10:01,280 it's going to return hash it's going to be called hash password. 125 00:10:01,650 --> 00:10:02,700 All right. 126 00:10:02,700 --> 00:10:12,140 And then it's going to accept a string of a parameter of type String and we're calling it password. 127 00:10:12,150 --> 00:10:12,560 All right. 128 00:10:12,960 --> 00:10:20,340 So inside of this function no we're going to start doing all of that stuff with the SHA 256 so I put 129 00:10:20,340 --> 00:10:27,720 the code in there and then I have to include my references so include in the reference and then I'm 130 00:10:27,720 --> 00:10:32,130 going to just take all of the code that we used in the log in. 131 00:10:32,130 --> 00:10:36,860 So all of this where we're doing the string builder and building it up. 132 00:10:37,290 --> 00:10:37,660 All right. 133 00:10:37,660 --> 00:10:42,970 So I'm going to just cut all of this because I don't want to log in anymore. 134 00:10:43,020 --> 00:10:47,100 So this is parts are refractory or when you realize that code is repeating itself. 135 00:10:47,100 --> 00:10:52,580 And then if you have to modify one base of 10 other places you just do it one place and reuse it right. 136 00:10:52,590 --> 00:11:01,380 So we have our SHA 256 objects we do our bytes we rebuild our string and then the last thing that we 137 00:11:01,380 --> 00:11:05,550 did was to say as a builder to string. 138 00:11:05,580 --> 00:11:14,010 So what I do is take this line and then I'll see who returns our function is going to return the string 139 00:11:14,010 --> 00:11:15,090 build a dot to string. 140 00:11:15,090 --> 00:11:19,630 So this is the final voted out what I've been assigned to the hashed password. 141 00:11:19,650 --> 00:11:26,370 So after getting a password value through the parameter we go through all of that and then we return 142 00:11:26,610 --> 00:11:27,930 the rebuild string. 143 00:11:27,930 --> 00:11:36,690 So that means anybody who wants this this hushed password will have to make a function call where it 144 00:11:36,690 --> 00:11:38,420 is say the hushed password. 145 00:11:38,430 --> 00:11:49,350 So this modify this log in function as a hash password is equal to utilize dot hash password and then 146 00:11:49,350 --> 00:11:51,440 this is expecting some string. 147 00:11:51,570 --> 00:11:55,220 And I'm going to pass in the password that we want touched. 148 00:11:55,230 --> 00:11:55,700 All right. 149 00:11:56,040 --> 00:11:57,500 So that looks much cleaner. 150 00:11:57,500 --> 00:11:57,930 Easy. 151 00:11:57,960 --> 00:12:01,600 Just one line of code to get the hashed password. 152 00:12:01,650 --> 00:12:03,090 All right. 153 00:12:03,090 --> 00:12:06,410 And then just the same way we did that in the log in. 154 00:12:06,450 --> 00:12:07,760 We just did that in the log in. 155 00:12:07,770 --> 00:12:12,690 We had no business doing that in the log and I'm just doing it one time because I'm about to do it again 156 00:12:12,690 --> 00:12:14,240 and let me just save you tools. 157 00:12:14,310 --> 00:12:17,090 I'm about to do it again instead of moneyed users. 158 00:12:17,190 --> 00:12:23,630 So my new password is going to be equal to and I just caught this. 159 00:12:23,640 --> 00:12:33,270 So instead of let me just say var generic password is equal to that string. 160 00:12:33,310 --> 00:12:33,710 All right. 161 00:12:33,740 --> 00:12:38,130 So I like to give my my values variable names. 162 00:12:38,130 --> 00:12:42,680 I don't like to have random values anywhere because then if somebody stumbled upon password I'd say 163 00:12:42,680 --> 00:12:45,700 in 1 2 3 they would be wondering what in the world that is right. 164 00:12:45,720 --> 00:12:51,720 So I just puts it in a variable and then I'm going to see a new password or I could just say a hushed 165 00:12:51,720 --> 00:13:01,340 password or it here is going to be equal to utilize dot and then hash password and then I'm going to 166 00:13:01,340 --> 00:13:06,790 pass in my generic password as a password I would like to get hushed. 167 00:13:06,810 --> 00:13:07,810 There you go. 168 00:13:07,820 --> 00:13:13,730 So we don't have to repeat all those lines of code every time we want to hash up BUZZER we just roll 169 00:13:13,730 --> 00:13:19,520 it off function inside of us static glass that's just going to take a value and then give us back a 170 00:13:19,520 --> 00:13:21,410 hushed password. 171 00:13:21,410 --> 00:13:22,770 All right. 172 00:13:23,120 --> 00:13:28,000 So that is our that is how we hash. 173 00:13:28,000 --> 00:13:31,150 So you see I wanted to introduce what we'll call a salt. 174 00:13:31,150 --> 00:13:35,860 Then we could have just introduced it instead of the utility because then everything is happening here 175 00:13:35,860 --> 00:13:36,540 anyway. 176 00:13:36,640 --> 00:13:43,420 So you could just say I just saw to the password and then do with the hashing and then so no one saw 177 00:13:43,420 --> 00:13:48,360 as he wanted to change us all will change at one place not not changing I saw it is recommended anyway 178 00:13:48,610 --> 00:13:53,870 but that's the point of having all of your code as centralized as possible all right. 179 00:13:53,880 --> 00:13:59,210 So now that we've calculated so we've got the user right presumably. 180 00:13:59,340 --> 00:14:00,900 And let me just change this. 181 00:14:00,930 --> 00:14:05,040 This object names so it's user var user. 182 00:14:05,040 --> 00:14:05,420 All right. 183 00:14:05,430 --> 00:14:14,040 So we retrieve the user and then we got the password we hash the password and then I'm just going to 184 00:14:14,040 --> 00:14:18,340 see user dot password. 185 00:14:18,340 --> 00:14:18,720 All right. 186 00:14:18,730 --> 00:14:22,300 So remember that we retrieved the user from the database. 187 00:14:22,300 --> 00:14:23,210 All right. 188 00:14:23,220 --> 00:14:26,450 And then we you know set the generic password. 189 00:14:26,460 --> 00:14:29,050 We hashed the generic password. 190 00:14:29,250 --> 00:14:35,400 So now I'm seeing that this user from the database your new password value is going to be equal to whatever 191 00:14:35,400 --> 00:14:41,050 came back from our function and got stored in our variable hashed password. 192 00:14:41,370 --> 00:14:49,630 Then I can just say on the score D.B. dot save changes because then it's sorry to trucking that way 193 00:14:49,660 --> 00:14:55,920 I just got this user back from the database I changed a property in this user from the database so to 194 00:14:55,920 --> 00:14:57,180 see if that changes. 195 00:14:57,200 --> 00:14:57,620 Right. 196 00:14:57,750 --> 00:14:59,490 And that's our ball in a reset. 197 00:14:59,490 --> 00:15:09,040 And then at the end of that you probably want to give a message box to say that Reese parser it has 198 00:15:09,040 --> 00:15:15,150 been reset so you could even be a bit more explicit you could let them know that. 199 00:15:15,760 --> 00:15:18,010 Now just use some interpolation here. 200 00:15:18,040 --> 00:15:21,180 User dot user name. 201 00:15:21,730 --> 00:15:22,130 All right. 202 00:15:22,150 --> 00:15:30,880 I'm going to say which user name and then apostrophe s just to be you know punctuation and grammatically 203 00:15:30,880 --> 00:15:31,850 correct. 204 00:15:32,020 --> 00:15:41,730 So user dot user names the password has been reset all right and that's it. 205 00:15:42,090 --> 00:15:47,430 So we just did a password reset to a nice simple click under two password reset of course like I said 206 00:15:47,430 --> 00:15:50,800 for the password I use that generic password. 207 00:15:50,880 --> 00:15:57,480 But then in practical terms you probably want to generate this on the fly and then let the person know 208 00:15:57,480 --> 00:15:58,320 the pattern. 209 00:15:58,350 --> 00:16:02,040 So that's part of security you would never want to tell the person that your new password is password 210 00:16:02,060 --> 00:16:02,250 at. 211 00:16:02,260 --> 00:16:08,340 One two three because then anybody can go in that person's a code and the ones that password has been 212 00:16:08,340 --> 00:16:08,640 set. 213 00:16:08,640 --> 00:16:11,580 If this is the password has been used way every single person. 214 00:16:11,580 --> 00:16:14,230 So security wise you'd want to tell them that it's there. 215 00:16:14,370 --> 00:16:19,220 The first four letters of the first name the last two letters of the last name and the date of birth 216 00:16:19,230 --> 00:16:25,170 something that only they should be able to sit down and figure out easily and probably be a little bit 217 00:16:25,170 --> 00:16:27,570 more difficult for somebody else to figure out. 218 00:16:27,570 --> 00:16:28,290 All right. 219 00:16:28,290 --> 00:16:32,490 So that's a nice cool under two way of doing the reset password function. 220 00:16:32,490 --> 00:16:35,870 Now a similar thing would be for the deactivate user. 221 00:16:35,870 --> 00:16:38,760 So I'm just going to take this strike catch. 222 00:16:38,880 --> 00:16:39,270 All right. 223 00:16:39,300 --> 00:16:41,600 And we're just going to modify the code a little. 224 00:16:41,600 --> 00:16:48,890 So once again we retrieve the person who was selected then we retrieve them from the database. 225 00:16:48,900 --> 00:16:51,940 Well then we don't need any hashing off anything. 226 00:16:51,960 --> 00:16:52,560 All right. 227 00:16:52,620 --> 00:16:59,910 What I am going to change however is there is active state somewhere to see a user that is active is 228 00:16:59,910 --> 00:17:05,540 equal to falls all right as a mother off. 229 00:17:05,580 --> 00:17:12,630 Well this is deactivated so I should probably build in putting functionality to see that you know if 230 00:17:12,630 --> 00:17:17,180 that same button is clicked then it would be activated or deactivated. 231 00:17:17,190 --> 00:17:23,730 So I would have to change to the cuing are the representation of the text on this button. 232 00:17:24,090 --> 00:17:32,880 So what I would do is say change the text to say the activates flash activate user. 233 00:17:32,880 --> 00:17:33,180 Right. 234 00:17:33,480 --> 00:17:38,730 So then the person would be clicking this button would know that this is a button that would deactivate 235 00:17:38,730 --> 00:17:41,760 the person or reactivate them. 236 00:17:41,760 --> 00:17:47,670 So if they're active deactivate and vice versa then the code that we would right is that on button click 237 00:17:47,700 --> 00:17:50,280 and we retrieve the user. 238 00:17:50,280 --> 00:17:56,320 All right then we're going to see if something like I'm just going to use a Turner operator here as 239 00:17:56,320 --> 00:18:05,370 I'll see user dot is active is equal to and then the ternary operator to know would allow me to state 240 00:18:05,370 --> 00:18:17,690 the condition someone to see a user that is active and I have to specify the condition is equivalent 241 00:18:17,690 --> 00:18:20,840 to true no if is active was not knowledgeable. 242 00:18:20,830 --> 00:18:23,810 So if you hover over it you see a bull with a question mark. 243 00:18:23,810 --> 00:18:29,180 That's because we made we are load nodes in the database and so it is B and C sharp. 244 00:18:29,180 --> 00:18:34,670 If it was not knowledgeable and it was just a straight boolean I could just say it is active and then 245 00:18:34,670 --> 00:18:36,920 say is true our false here right. 246 00:18:36,920 --> 00:18:39,580 What happens if it's true what happens is if it's false. 247 00:18:39,680 --> 00:18:44,820 Well because it's normal we introduced a third states where it could be no it will be true false. 248 00:18:44,910 --> 00:18:46,280 Ah no. 249 00:18:46,310 --> 00:18:46,840 Right. 250 00:18:46,850 --> 00:18:50,140 So because of that I have to specify is equivalent to true. 251 00:18:50,150 --> 00:18:53,870 So we're seeing if the user is active. 252 00:18:53,900 --> 00:19:01,430 If only you looked up the user in the database I would find that there they are active if is active 253 00:19:01,430 --> 00:19:07,100 is true then we want to set it to falls otherwise so it's a true. 254 00:19:07,100 --> 00:19:07,430 Right. 255 00:19:07,430 --> 00:19:13,050 So it would just be like an if statement if is active is true then is active should equal to falls. 256 00:19:13,130 --> 00:19:15,540 Ls is active should equal to true right. 257 00:19:15,530 --> 00:19:18,820 That's that's basically what we did in this one line. 258 00:19:18,870 --> 00:19:19,600 All right. 259 00:19:19,670 --> 00:19:24,530 So I could add a comment here to say this is what it would look like as an if else. 260 00:19:24,620 --> 00:19:30,010 All right so that's what it would look like if the user is if the user is active. 261 00:19:30,190 --> 00:19:32,600 That's equivalent to true then we set it to false. 262 00:19:32,750 --> 00:19:33,900 As we set it to true. 263 00:19:33,920 --> 00:19:35,940 So that's what this one line does. 264 00:19:35,990 --> 00:19:43,520 So in the person or the user clicks deactivate user it gets the role that was selected and then he gets 265 00:19:43,520 --> 00:19:50,460 the user associated with the idea of the role that was selected and then we see the user is active. 266 00:19:50,630 --> 00:19:59,000 A is relative to what I was true or false then we see the changes and then we see a user user name or 267 00:19:59,000 --> 00:20:08,660 has been our activities that process change active status has changed. 268 00:20:08,990 --> 00:20:16,660 So I'm just I'm just leaving it generic here because the thing is I would have to probably put in an 269 00:20:16,660 --> 00:20:19,600 if statement to see whether it's true or false at the end of that. 270 00:20:19,600 --> 00:20:26,040 If it was activated or deactivated so I'll just leave it to try and keep it simple and just see you 271 00:20:26,040 --> 00:20:29,280 know the active status has changed. 272 00:20:29,380 --> 00:20:29,770 All right. 273 00:20:30,040 --> 00:20:39,100 So right there we would have done two very major operations and we would have done it with much simplicity 274 00:20:39,610 --> 00:20:45,650 click under to at some points but I did explain why and how you could enhance it for yourself. 275 00:20:45,820 --> 00:20:48,400 And so that's it for this lesson. 276 00:20:48,400 --> 00:20:57,070 Next time we come along we will be populating our grid and then focusing on adding users to our application.