1 00:00:00,940 --> 00:00:06,130 Hey guys we'll come back in this video we're going to get the party started officially and actually 2 00:00:06,130 --> 00:00:13,670 look at how we can go about adding users and while managing their experience with our application so 3 00:00:13,670 --> 00:00:19,960 we'll be adding users selecting the role that they're in and generating a default password and then 4 00:00:19,960 --> 00:00:26,950 we'll have to modify or log in process such that when person's log in using that default password we 5 00:00:27,070 --> 00:00:32,240 we redirect them to a screen that allows them to change this password. 6 00:00:32,260 --> 00:00:37,530 Now before I move on I'm going to show you a little adjustments I made to my main window where I did 7 00:00:37,700 --> 00:00:43,000 a little bar at the bottom here and I have the takes us is logged in as call on. 8 00:00:43,030 --> 00:00:45,680 And the user name someone to show you how to do that. 9 00:00:45,690 --> 00:00:50,610 And it's really simple but these simple things you know make your application come to life. 10 00:00:50,620 --> 00:00:59,740 So what I did in my design for my mean window was to add what I call what they call sorry context strip. 11 00:00:59,740 --> 00:01:02,100 So I went to a stateless strip brother. 12 00:01:02,110 --> 00:01:10,960 So I went to the tool box and then I got inside of menus and the toolbars one that says status strip. 13 00:01:10,960 --> 00:01:18,780 So I just drug that over dropped it though the bottom part here and then I did stateless label someone 14 00:01:18,780 --> 00:01:21,240 to click stateless label initially what that looks like. 15 00:01:21,700 --> 00:01:24,870 So I got tools trip status label all right. 16 00:01:25,300 --> 00:01:30,310 But obviously that is what will get printed to the user that's not what we want printed to the user. 17 00:01:30,310 --> 00:01:34,870 So what I did was modify the properties one by changing the name. 18 00:01:35,470 --> 00:01:41,560 So I changed the name to something I could identify change it to TSA log in text. 19 00:01:41,560 --> 00:01:42,910 That's what I called it. 20 00:01:43,030 --> 00:01:47,940 But I also removed the text because I don't want that takes to be showing. 21 00:01:48,250 --> 00:01:52,650 And then clearly whatever it takes is going to be displayed is going to be contextual. 22 00:01:52,680 --> 00:01:53,020 Right. 23 00:01:53,470 --> 00:01:59,590 So after renaming it and I'm going to delete this one that I just created because I don't need the. 24 00:01:59,600 --> 00:02:00,040 All right. 25 00:02:00,040 --> 00:02:07,660 So I guess it's going to be difficult for me to remove it because he got condensed but that's fine in 26 00:02:07,660 --> 00:02:15,610 the window load function though I did say that I want the user name to be whatever we got back in our 27 00:02:15,610 --> 00:02:17,520 user objects not user name. 28 00:02:17,540 --> 00:02:24,070 So remember we have or user objects that we're sitting here and initializing instead of a constructor 29 00:02:24,070 --> 00:02:27,520 once the person logs in who are passing over that entire object. 30 00:02:27,520 --> 00:02:29,770 So we have access to everything about this user. 31 00:02:29,920 --> 00:02:35,930 And then what I'm choosing to display in that text is and I got a TSA log in text. 32 00:02:35,930 --> 00:02:36,280 All right. 33 00:02:36,310 --> 00:02:38,800 So I call the TSA tool strip item. 34 00:02:38,830 --> 00:02:39,940 That's just me. 35 00:02:39,940 --> 00:02:42,520 That's my prefix that I'm using. 36 00:02:42,520 --> 00:02:47,290 But I would say TSA log in text not text is going to be equal to. 37 00:02:47,400 --> 00:02:50,170 And then I said logged in as Hold on. 38 00:02:50,170 --> 00:02:54,510 And then I'm passing in that user name that I got from my User object. 39 00:02:54,520 --> 00:02:54,850 Right. 40 00:02:55,330 --> 00:03:01,990 So when the main window loads it will know who is logged in and it was really that simple. 41 00:03:01,990 --> 00:03:02,190 All right. 42 00:03:02,200 --> 00:03:08,090 So moving on what we want to do is activate our ad log in. 43 00:03:08,460 --> 00:03:09,060 But right. 44 00:03:09,070 --> 00:03:14,390 So we have the manage user screen we already have our database context object. 45 00:03:14,440 --> 00:03:21,520 We already did our password reset and deactivate user functions and all we need some functionality instead 46 00:03:21,520 --> 00:03:22,630 of add user. 47 00:03:22,630 --> 00:03:26,530 So in order to add user I need another form which I did not create. 48 00:03:26,530 --> 00:03:27,750 So we'll do that together. 49 00:03:27,880 --> 00:03:34,260 And then when you right click my solution go to add take form and then I'm going to add the form and 50 00:03:34,260 --> 00:03:36,010 I want to call it add user. 51 00:03:36,010 --> 00:03:42,220 So I'm not allowing you to edit the user is just add users I literally just want to add user as a form 52 00:03:42,490 --> 00:03:49,640 click add and then we make our usual cosmetic changes where we change the text in the address bar to 53 00:03:49,790 --> 00:03:57,980 the user and then I'm just going to widen it a bit I'm also going to copy some stuff from all one of 54 00:03:57,980 --> 00:04:01,860 our existing add edit screens of updated vehicles. 55 00:04:01,990 --> 00:04:09,180 And the reason I'm copying this is all right someone to use our entire record and then I are the reason 56 00:04:09,180 --> 00:04:14,370 I'm using our entire record is I just noticed that I'd edit vehicle did not have that you know that 57 00:04:14,370 --> 00:04:15,500 label at the top. 58 00:04:15,570 --> 00:04:25,230 We also didn't do the cosmetic changes so I may have overlooked that part with the edit vehicle but 59 00:04:25,230 --> 00:04:27,440 we can make those adjustments later. 60 00:04:27,480 --> 00:04:29,780 So I really just want the label. 61 00:04:29,780 --> 00:04:37,440 So I'm taking this label and moving it all with the user putting into the top changing the text in there. 62 00:04:37,440 --> 00:04:40,270 So that's AD user. 63 00:04:40,270 --> 00:04:40,650 All right. 64 00:04:40,650 --> 00:04:43,730 And then we can of course recenter it. 65 00:04:43,740 --> 00:04:47,340 All right then I'm going to use my label. 66 00:04:47,370 --> 00:04:54,900 So I have been using the table labeled for these forms so I want to use the container and it's going 67 00:04:54,900 --> 00:04:57,970 to be the table layout panel. 68 00:04:58,050 --> 00:04:58,920 All right. 69 00:04:58,920 --> 00:05:03,960 And then what does a user have a user for user would probably want to set. 70 00:05:03,990 --> 00:05:05,920 Only the user name. 71 00:05:05,940 --> 00:05:11,460 Right so you don't want to allow your users are your admin user to be setting the password remember 72 00:05:11,460 --> 00:05:13,650 where the hardcoded generic password. 73 00:05:14,070 --> 00:05:19,600 So we'll leave that generic password that when they click submit that's all that gets grouped. 74 00:05:19,620 --> 00:05:24,410 So I'm actually just going to resize this since it's not going to be that big of a window. 75 00:05:24,540 --> 00:05:31,050 So I do user move or table I know our table container a little bit. 76 00:05:31,050 --> 00:05:40,110 We bring over our labels so under common controls I bring over my label and then this label property 77 00:05:40,470 --> 00:05:44,630 I'm going to set that takes to be user name. 78 00:05:44,940 --> 00:05:45,830 All right. 79 00:05:45,990 --> 00:05:54,070 And then I'm going to bring over a text box so then the text box for the user name sorry. 80 00:05:54,360 --> 00:06:00,630 So don't forget where the things are text box so we can add the user name and then the next thing that 81 00:06:00,640 --> 00:06:03,970 would be setting for this user is the role. 82 00:06:03,980 --> 00:06:10,800 Now remember that the rules are all stored in a table called rules which means that I would probably 83 00:06:10,800 --> 00:06:12,260 need a dropdown list. 84 00:06:12,270 --> 00:06:18,750 So let me just copy and paste this username label and then I'm going to change this one to say rule 85 00:06:19,500 --> 00:06:25,490 but then for the rule I'll be taking this from a predetermined list in a combo box. 86 00:06:25,640 --> 00:06:30,310 So I made a struggle with this combo box and then we did a combo box before. 87 00:06:30,330 --> 00:06:37,770 So what I'm going to do is just me at this table Leo to be bigger so that we can strip you know maximize 88 00:06:37,770 --> 00:06:45,150 on the space a bit more we can expand our controls a bit more and then for the combo box we have to 89 00:06:45,150 --> 00:06:51,660 modify the properties where Wanda wanted to actually be dropdown lists so I don't want anybody to be 90 00:06:51,660 --> 00:06:53,370 able to type in there. 91 00:06:53,460 --> 00:06:58,530 Also the functions are the items sorry would not be hardcoded. 92 00:06:58,560 --> 00:07:03,410 So we'd have to set that from the code behind when this form loads. 93 00:07:03,420 --> 00:07:03,680 All right. 94 00:07:03,690 --> 00:07:07,350 So we need a load function so that it was at the farm. 95 00:07:07,450 --> 00:07:09,680 How we've got the Lord function. 96 00:07:09,690 --> 00:07:10,020 All right. 97 00:07:10,350 --> 00:07:17,450 So in order to load in the items we did something like this already when we were adding the car into 98 00:07:17,460 --> 00:07:18,060 our record. 99 00:07:18,060 --> 00:07:24,330 So if you want we can go back to the add edit or into our record and then we can look at the load function 100 00:07:24,330 --> 00:07:32,250 that we did for this one where we said we want to query the table for all of the cars in the table and 101 00:07:32,250 --> 00:07:38,760 then we want to populate our combo box so we need to do something very similar where we just get back 102 00:07:38,760 --> 00:07:45,490 to my design I want to see that first of my text box for the user name is going to be TB user name so 103 00:07:45,490 --> 00:07:56,960 then we go to properties and change that TB user name and then the combo box is going to be CB rules. 104 00:07:56,960 --> 00:08:01,440 All right CB rules or rule list or something like that. 105 00:08:01,470 --> 00:08:09,510 But once you have the prefix and the appropriate title afterwards and so then what we want to do is 106 00:08:09,510 --> 00:08:15,680 populate this combo box list with the rules and the appropriate value and data members. 107 00:08:15,680 --> 00:08:20,280 So I need to initialize my database object. 108 00:08:20,280 --> 00:08:20,600 All right. 109 00:08:20,610 --> 00:08:22,610 So we have our database object. 110 00:08:22,620 --> 00:08:30,280 The next thing that I want to do is to actually put the function call or the query in here some would 111 00:08:30,280 --> 00:08:40,410 just have virals is equal to database objects dots table which is rules dot and then I just want to 112 00:08:40,410 --> 00:08:41,110 list. 113 00:08:41,140 --> 00:08:41,730 All right. 114 00:08:42,270 --> 00:08:50,580 So I just want the entire list of rules phoned in the database which we know is really the I.T. the 115 00:08:50,650 --> 00:08:53,620 admin sorry the I.T. the name on the short name. 116 00:08:53,670 --> 00:08:55,250 Those are the columns. 117 00:08:55,270 --> 00:09:01,860 And so then I'm went to say CB dot sorry CB rolls. 118 00:09:02,240 --> 00:09:03,100 Right. 119 00:09:03,150 --> 00:09:11,840 That's data source is equal to or or variable rules that we just declared. 120 00:09:11,850 --> 00:09:26,590 And then CB rules that value member is equal to and then we'll see that it is I.D. and then we assess 121 00:09:26,610 --> 00:09:39,840 CB rules that display a member sorry display member is equal to and then we're displaying the name not 122 00:09:39,840 --> 00:09:42,110 the shirt name but the name this time. 123 00:09:42,870 --> 00:09:43,430 So that's it. 124 00:09:43,440 --> 00:09:49,180 The data source we set the volume member and we set the display a member. 125 00:09:49,290 --> 00:09:56,820 And after all of that we want this ad user window to be launched on the click of the ad user button. 126 00:09:56,820 --> 00:09:59,700 So Liam just go back to my manage user. 127 00:09:59,730 --> 00:10:01,570 So this is a button click event. 128 00:10:01,740 --> 00:10:11,160 So of course we know we need to declare an object the user is equal to new and then went to see it AD 129 00:10:11,430 --> 00:10:16,680 user as my initialization. 130 00:10:16,680 --> 00:10:23,640 Then I went to see AD user so that the objects MDI parents 131 00:10:26,810 --> 00:10:33,620 is equal to and then it's going to be this dot MDI appearance remember that we just want to declare 132 00:10:34,280 --> 00:10:45,330 them they appear to be that and then I'm going to see AD user dot show but then I remember of course 133 00:10:45,330 --> 00:10:48,480 we want to make sure that only one instance of this shows. 134 00:10:48,480 --> 00:10:54,150 So we need to put all of this inside of that statement so I need to check if I'm just going to say you 135 00:10:54,160 --> 00:11:02,010 tills dot farm is open and then I pass in the name of the form that I want to check if it's open which 136 00:11:02,010 --> 00:11:10,520 is AD user so if not meaning if the farm is not open then I want to do all of that. 137 00:11:10,530 --> 00:11:17,570 So when you click ad user only one instance should ever appear because of this if statement. 138 00:11:17,580 --> 00:11:19,020 No we're not finished with this. 139 00:11:19,020 --> 00:11:22,640 The next thing that we want to make sure we have is the button. 140 00:11:22,710 --> 00:11:28,970 So we have a quite a submit button and I'm also going to put a cancel button. 141 00:11:29,060 --> 00:11:29,840 Right. 142 00:11:29,870 --> 00:11:32,060 So you could submit that okay. 143 00:11:32,070 --> 00:11:37,540 Yes this is a user you want to create and you could also consider operation it. 144 00:11:37,580 --> 00:11:41,440 So let me just do those two buttons so button one. 145 00:11:41,450 --> 00:11:49,100 I'm going to go to properties and I'm going to call it what I'm want to say submit firstly and then 146 00:11:49,130 --> 00:11:57,860 it's going to have the name Beatty and submit and then for button 2 I'm going to make similar changes 147 00:11:57,860 --> 00:12:06,800 where button to that name is going to be Beatty and cancel and the text is going to see cancel it and 148 00:12:06,830 --> 00:12:09,710 then for the cancel button all I'm want to see is close. 149 00:12:09,710 --> 00:12:15,030 So if it gets clicked I just said doesn't create that I click event and I'm seeing if you click cancel 150 00:12:15,050 --> 00:12:16,060 just close the window. 151 00:12:16,070 --> 00:12:17,210 That's easy enough right. 152 00:12:17,720 --> 00:12:21,460 And then if you click submit then we want to do something else. 153 00:12:21,470 --> 00:12:26,890 So when you click submit is when we actually want to add the user that you're entering to the database. 154 00:12:26,890 --> 00:12:27,100 Right. 155 00:12:27,500 --> 00:12:32,370 So then I need to declare a new object of type users. 156 00:12:32,370 --> 00:12:44,480 I want to say var users equal to a new user all right and then I need to collect data from the forum 157 00:12:44,490 --> 00:12:46,500 so let me do that first actually. 158 00:12:46,540 --> 00:12:55,290 Someone to say var user name is equal to and then I know TB user name dot text. 159 00:12:55,290 --> 00:12:56,330 So that's his user name. 160 00:12:56,330 --> 00:12:58,070 That was just entered right. 161 00:12:58,190 --> 00:13:11,640 And then would just say var roll I E is equal to the selected value of this combo box so CB rules dot 162 00:13:11,840 --> 00:13:14,030 select Ted. 163 00:13:14,120 --> 00:13:19,790 And that's index that's item about what I want is selected value. 164 00:13:19,800 --> 00:13:20,870 Right. 165 00:13:20,940 --> 00:13:23,720 Well then of course this is going to be of type object. 166 00:13:23,730 --> 00:13:29,940 I need it on in so I'm just going to implicitly typecast it to an integer so no role. 167 00:13:29,950 --> 00:13:32,960 I.D. is integer a selected value. 168 00:13:33,060 --> 00:13:35,250 What does the Zi User object have. 169 00:13:35,280 --> 00:13:37,390 So we have the user name we have the rule. 170 00:13:37,410 --> 00:13:40,010 Well we don't give out a password and the active stuff. 171 00:13:40,030 --> 00:13:41,640 Only if I just created the user. 172 00:13:41,730 --> 00:13:46,700 I'm going to assume that the activity is true. 173 00:13:46,740 --> 00:13:47,190 Right. 174 00:13:47,190 --> 00:13:51,110 I don't know why I would create an inactive user someone to leave. 175 00:13:51,110 --> 00:13:55,440 That's as true by default if they want to change it later on they can go ahead and do that from the 176 00:13:55,440 --> 00:13:56,700 management screen. 177 00:13:56,880 --> 00:14:03,480 But I have the role idea and I have the user name and then the next thing would be the password. 178 00:14:03,510 --> 00:14:09,960 So if you recall we have a default password that we use when we recently did the reset password functionality 179 00:14:09,990 --> 00:14:17,100 and I can review that and show you in the money's user we did reset password button where we set that 180 00:14:17,100 --> 00:14:18,270 to the default password. 181 00:14:18,280 --> 00:14:24,960 Now if I wanted to retain this as a default password then that means that I have it hardcoded here and 182 00:14:24,960 --> 00:14:31,710 I have it hard both to hardcoded in this next function which is not good because then if I need to change 183 00:14:31,710 --> 00:14:35,750 it I may change it one based on not remember it's a change that other place. 184 00:14:35,820 --> 00:14:38,200 So it's easy if we have it's one pretty right. 185 00:14:38,580 --> 00:14:46,110 So I'm actually just going to create another function in the utilize where I'm going to see default 186 00:14:46,110 --> 00:14:47,180 hash password. 187 00:14:47,190 --> 00:14:49,740 So I'm just going to take all of this. 188 00:14:49,760 --> 00:14:57,950 All right and I'm just going to copy and paste it and I'm going to call the function default hashed 189 00:14:58,160 --> 00:14:59,150 password. 190 00:14:59,210 --> 00:15:00,600 So this is just me me. 191 00:15:00,650 --> 00:15:05,930 You can name it something else but this one is not going to take any parameters because what I'm about 192 00:15:05,930 --> 00:15:10,650 to do is hash the default password and return that top right. 193 00:15:10,670 --> 00:15:14,350 So when's your return we replaced sorry. 194 00:15:14,480 --> 00:15:19,370 The reference being made to the variable password or we had departments are here. 195 00:15:19,400 --> 00:15:22,040 So the parameter is here now we have password. 196 00:15:22,190 --> 00:15:27,770 I'm replacing this because I just took all department out of this one and I'm replacing it with a hard 197 00:15:27,770 --> 00:15:32,060 coded password at 1 2 3. 198 00:15:32,060 --> 00:15:36,670 So that means if we want to change that default password we need only change it here. 199 00:15:36,770 --> 00:15:41,740 And every time we call this function it will just hash that default password that we have set. 200 00:15:41,750 --> 00:15:42,080 Right. 201 00:15:42,590 --> 00:15:48,110 So what I'm going to do having created this function is one go back to manage user and then I'm going 202 00:15:48,110 --> 00:15:53,860 to change this entire block of code no to just use my new function. 203 00:15:53,990 --> 00:15:59,670 And that's his default hashed password which takes no parameters. 204 00:15:59,740 --> 00:16:05,960 So all it is going to do is return a hashed version of whatever that static takes that we set is. 205 00:16:05,950 --> 00:16:08,670 So there are many ways you can make it more dynamic. 206 00:16:08,690 --> 00:16:11,440 I'm just trying to keep it simple before the purpose of learning. 207 00:16:11,840 --> 00:16:17,900 So we have YouTube's default attached password that was just hash whatever that text is that we the 208 00:16:18,110 --> 00:16:23,560 programmers or the business has determined is unacceptable default password. 209 00:16:23,600 --> 00:16:24,230 Right. 210 00:16:24,470 --> 00:16:29,810 And so I'd use it instead of money user someone to use it again instead of user when I'm adding the 211 00:16:29,810 --> 00:16:40,850 user I want the password to be YouTube's not default hushed password so they're getting a default password 212 00:16:40,880 --> 00:16:41,860 also. 213 00:16:41,870 --> 00:16:43,500 All right. 214 00:16:43,550 --> 00:16:48,740 Now I have the minimum requirements for a user I have the username of the password on our bulletin said 215 00:16:48,740 --> 00:16:55,490 activity status rule I.T. is not required in the user's tables so we soon get to that part but I'm going 216 00:16:55,490 --> 00:17:03,800 to see user dots and then actually I'm is really all you can do it with with the initialize or some 217 00:17:03,800 --> 00:17:09,470 was going to say var new user and the number's going to open and close the braces and then inside of 218 00:17:09,470 --> 00:17:16,490 these open and close braces just a little indentation here we're going to see the user name that should 219 00:17:16,490 --> 00:17:21,460 be here is equal to user name. 220 00:17:21,650 --> 00:17:22,760 All right. 221 00:17:22,980 --> 00:17:30,920 And then comma the password that this user is going to have is equal to the password variable comma 222 00:17:31,440 --> 00:17:36,030 and then the final one is is active is true. 223 00:17:36,030 --> 00:17:36,610 All right. 224 00:17:36,660 --> 00:17:42,990 So when we're about to submit a new user we call it the user name that was entered collect the password 225 00:17:43,180 --> 00:17:49,080 declare clear and you object of type user and then we fill in the columns put a similar code on their 226 00:17:49,080 --> 00:17:50,010 backs isn't. 227 00:17:50,190 --> 00:17:55,560 So we have user name is equal to username password is equal to password is active is true we can go 228 00:17:55,570 --> 00:18:04,180 about adding someone to say D.B. dot users some know when to say add this record to the user stable 229 00:18:04,170 --> 00:18:14,860 so a user database user stable add this user object and then after all of that we save changes. 230 00:18:14,940 --> 00:18:19,910 All right now let's see if this works. 231 00:18:19,910 --> 00:18:22,320 Someone to click Start. 232 00:18:22,880 --> 00:18:26,160 I logged in as the admin user so that I have access to the money. 233 00:18:26,160 --> 00:18:28,460 Users I click manage users. 234 00:18:28,460 --> 00:18:32,930 No we still haven't populated this grid and will soon get to that but let's click Add a user. 235 00:18:32,930 --> 00:18:35,030 And here we see our forum coming up. 236 00:18:35,240 --> 00:18:39,130 So they put in the user name and then we can select the roll. 237 00:18:39,130 --> 00:18:40,910 All right that looks good. 238 00:18:40,910 --> 00:18:46,640 So I am going to put it in another user and would to say admin one and this person this new user is 239 00:18:46,640 --> 00:18:51,140 going to be in the administrator role then click submit and I want to show you something. 240 00:18:51,170 --> 00:18:59,350 So before I click submit I am going to put a break point right that line four to eight. 241 00:18:59,390 --> 00:19:00,120 All right. 242 00:19:00,230 --> 00:19:04,340 So are my line 48 are the last line of this function. 243 00:19:04,460 --> 00:19:06,860 Because I want to check something with you. 244 00:19:06,890 --> 00:19:11,800 So we're going to click submit and then it got this far with no arrows. 245 00:19:11,810 --> 00:19:17,990 So my assumption is that it went through a created the user the password and then if we look at the 246 00:19:17,990 --> 00:19:25,100 user object and just drilled on we will see that we actually have an idea associated with this user 247 00:19:25,100 --> 00:19:26,710 so you can look at that hash. 248 00:19:26,750 --> 00:19:29,210 That's an entirely different hash from what we're used to. 249 00:19:29,300 --> 00:19:35,270 But what I want to point out is the fact that once we got this far and we added the record and we see 250 00:19:35,300 --> 00:19:44,870 the changes it automatically updated or a user object to have the I.D. that it got after it was added 251 00:19:44,870 --> 00:19:46,220 to the database. 252 00:19:46,220 --> 00:19:46,510 All right. 253 00:19:46,520 --> 00:19:52,910 So the relevance of that is remember that this user object is is plain it's dumb it's it's it's only 254 00:19:52,910 --> 00:19:53,930 knows all we tell it. 255 00:19:53,960 --> 00:19:59,150 So we only told it to have a user name were a little bit of a password and dove on is activity itself 256 00:19:59,160 --> 00:20:04,210 true we didn't give it an I.D. I these are being auto generated by the database. 257 00:20:04,340 --> 00:20:08,790 So the fact that it did this saved changes and then it continued it. 258 00:20:08,900 --> 00:20:15,830 The code can reflect that it was saved in the database and it no has an idea of for and that will come 259 00:20:15,830 --> 00:20:18,530 in handy and I'm going to show you exactly why. 260 00:20:18,530 --> 00:20:20,230 So I'm just going to continue. 261 00:20:21,060 --> 00:20:21,790 All right. 262 00:20:21,890 --> 00:20:26,960 And then well you know we need to put it on our track catch and our success message and to close the 263 00:20:26,960 --> 00:20:28,640 window after everything is done. 264 00:20:28,910 --> 00:20:30,500 So we have all of that to do. 265 00:20:30,590 --> 00:20:33,090 But I just want to focus on something first. 266 00:20:33,120 --> 00:20:39,200 Now remember that we just added a user and we selected the rule from the dropdown however based on how 267 00:20:39,200 --> 00:20:41,060 we have designed our rules. 268 00:20:41,060 --> 00:20:49,240 So if I just refresh this through your on this query real quickly then you would see sorry I clicked 269 00:20:49,240 --> 00:20:50,010 the wrong button. 270 00:20:50,020 --> 00:20:52,450 So we'll see our new user being added here. 271 00:20:52,450 --> 00:20:53,320 All right. 272 00:20:53,420 --> 00:20:59,820 All it's in our user rules table we don't have any reflection of any new user with any new rules. 273 00:20:59,830 --> 00:21:05,290 So of course if we're adding a new user and we're selecting the rule from the dropdown that we need 274 00:21:05,290 --> 00:21:13,240 to insert the rule accordingly or the user rule association in this table where the new user that was 275 00:21:13,240 --> 00:21:19,690 added with the idea that we just saw in this case was for has the rule I.D. that is associated with 276 00:21:19,690 --> 00:21:22,450 what was selected from our dropped on list. 277 00:21:22,540 --> 00:21:24,820 So we need to me that modification to our code. 278 00:21:25,150 --> 00:21:35,020 So after we've saved the change to add the user we can now see var user I.D. is equal to our user object 279 00:21:35,060 --> 00:21:38,640 dot the idea column on because no it has a value right. 280 00:21:38,650 --> 00:21:40,120 Like we just saw. 281 00:21:40,210 --> 00:21:40,540 No. 282 00:21:40,540 --> 00:21:46,660 After getting that user I.D. and we already have a role I.D. and the Middle East changes to come on 283 00:21:46,720 --> 00:21:48,600 are keeping consistent. 284 00:21:48,600 --> 00:21:55,210 So overall idea of user I.D. then I can go ahead and see underscore DBA dots. 285 00:21:55,280 --> 00:21:57,450 User rules are. 286 00:21:57,540 --> 00:21:57,910 Sorry. 287 00:21:57,930 --> 00:21:58,640 Sorry sorry. 288 00:21:58,720 --> 00:22:08,290 Skipping ahead of myself there says a var user roll is equal to a new object of user rule which is my 289 00:22:08,290 --> 00:22:09,130 table right. 290 00:22:09,130 --> 00:22:11,910 So I'm creating an object of type user or. 291 00:22:12,490 --> 00:22:19,800 And then just going to initialize it here and then the columns that I have our roll I.D. and user I.D.. 292 00:22:19,900 --> 00:22:20,470 All right. 293 00:22:20,470 --> 00:22:28,810 So roll I.D. is going to be equal to the value that I got from my combo box and then user I.D. is going 294 00:22:28,810 --> 00:22:35,340 to be equal to the value that I just got from a newly created user. 295 00:22:35,440 --> 00:22:43,150 And then after I do this then we know the next thing would be to add the record to the database IDB 296 00:22:43,160 --> 00:22:56,620 objects dot user rules dot add and then I'm going to see a user rule and then I'm going to say D.B. 297 00:22:57,250 --> 00:23:03,220 dot save changes or it coming on nicely. 298 00:23:03,400 --> 00:23:12,820 And then once this is done it will create the new user and then fetch the IP then assign him to the 299 00:23:12,820 --> 00:23:14,460 rule are her right. 300 00:23:14,460 --> 00:23:15,850 I send that user to the rule. 301 00:23:16,000 --> 00:23:19,820 So before I go into it I'm just going to put in the try catch. 302 00:23:19,900 --> 00:23:26,290 So just writing try pressing it up twice and then I've put all of that operation instead of the try 303 00:23:26,740 --> 00:23:28,740 and then I'm not one to throw. 304 00:23:28,990 --> 00:23:34,580 Instead I'm going to see a message box dot Sure. 305 00:23:35,230 --> 00:23:38,770 And then the message box does show. 306 00:23:38,770 --> 00:23:46,020 I'm just going to see an arrow has occurred or write something generic. 307 00:23:46,030 --> 00:23:52,420 You can always get as specific as you want but then you know we've been through this quite a few times 308 00:23:53,050 --> 00:24:01,480 and then after a successful ad operation I do want to display a message box saying sorry. 309 00:24:02,500 --> 00:24:05,320 All right see a new user added successfully. 310 00:24:05,350 --> 00:24:10,620 So just a new user added success fully. 311 00:24:11,590 --> 00:24:17,900 And then I will close the window all right. 312 00:24:18,350 --> 00:24:19,050 And then. 313 00:24:19,220 --> 00:24:21,800 Well that's pretty much it for the ad user. 314 00:24:21,800 --> 00:24:29,500 So let's just try it out one more time so I'm going to click start then we log in go to manage users 315 00:24:29,530 --> 00:24:30,950 then add new user. 316 00:24:31,060 --> 00:24:35,030 And then this time I'm going to save you Clark. 317 00:24:35,530 --> 00:24:40,170 That's this person's username and I'm setting them to be view only. 318 00:24:40,270 --> 00:24:45,820 And then I click submit and then it says news user added successfully I click Okay. 319 00:24:45,880 --> 00:24:50,350 And then the other breakpoint is still there so I remove the breakpoint and then continue. 320 00:24:50,350 --> 00:24:52,360 And then we're back at our main window. 321 00:24:52,360 --> 00:24:54,880 We haven't done anything with the grid just yet. 322 00:24:54,880 --> 00:25:03,430 But then if I go to my database and I read execute this query then I'm going to see a third rule. 323 00:25:03,460 --> 00:25:03,940 Right. 324 00:25:03,940 --> 00:25:05,590 With user I.D. five. 325 00:25:05,620 --> 00:25:11,090 So remember that before no use ideals force and 0 5 and the rule I.D. 3. 326 00:25:11,100 --> 00:25:18,150 And if I go over to users and re execute this query then I'm going to see my view clerk with use eighty 327 00:25:18,150 --> 00:25:22,440 five and then the password because they both have the same default password. 328 00:25:22,450 --> 00:25:24,370 So these two passwords are the same. 329 00:25:24,370 --> 00:25:27,430 These two passwords are the same the hashes are the same right. 330 00:25:27,850 --> 00:25:32,980 So it's I mean it's not but if the hashes are to see and the point is that you know if you look at it 331 00:25:32,980 --> 00:25:37,330 you can't tell if I didn't tell you which one was which you wouldn't know which password or what the 332 00:25:37,330 --> 00:25:42,320 English word or equivalent of these passwords would be. 333 00:25:42,340 --> 00:25:48,820 So the next thing that's I want to do know is to modify my money's user's windows so that when the user 334 00:25:48,820 --> 00:25:55,540 gets added or you know deactivated or something that it should reflect here that that data is going 335 00:25:55,540 --> 00:25:56,180 to be affected. 336 00:25:56,170 --> 00:25:57,800 So I'm actually going to do it. 337 00:25:57,880 --> 00:26:04,960 I want you to pause the video and attempted yourself and I'm going to pause right here do it and then 338 00:26:04,960 --> 00:26:06,600 I'll come back and explain it to you. 339 00:26:06,610 --> 00:26:10,920 But I would really encourage you to try it on your own. 340 00:26:10,950 --> 00:26:16,710 All right so I'm just going to walk you through the adjustments I made and I hope you you know pause 341 00:26:16,710 --> 00:26:22,110 the video you attempted it and if you see a and feeling comfortable enough and you are aware you are 342 00:26:22,110 --> 00:26:24,780 waiting on me then that's fine I'll walk you through what I did. 343 00:26:25,260 --> 00:26:32,430 So I created a similar function to what we've been doing up on you know called populates grid and in 344 00:26:32,430 --> 00:26:33,260 populate grid. 345 00:26:33,270 --> 00:26:36,590 I run a query where I sit and he's yes I love cars. 346 00:26:36,600 --> 00:26:40,500 That's because I actually copied and pasted the code from our previous work. 347 00:26:40,500 --> 00:26:40,800 Right. 348 00:26:40,800 --> 00:26:47,290 So in this case then we just change it quickly and so it shouldn't see a car as it should say users. 349 00:26:47,370 --> 00:26:54,870 So I got the users I selected into that new abstract object getting the idea the user name the rolls. 350 00:26:54,870 --> 00:26:56,890 So no I had to do kudos. 351 00:26:56,910 --> 00:27:04,860 User rules that first default to get the first rule or you know it's a list of rules based on the data 352 00:27:04,890 --> 00:27:05,660 construct. 353 00:27:05,670 --> 00:27:07,350 But in reality it's one rule. 354 00:27:07,380 --> 00:27:07,800 Right. 355 00:27:08,130 --> 00:27:09,660 So I'm just saying give me the list. 356 00:27:09,660 --> 00:27:14,410 I know it's only 1 in the list but the way they process it it see that list starts 1. 357 00:27:14,430 --> 00:27:20,390 So since it's a list give me the first one in the list and then tell me the roll name. 358 00:27:20,400 --> 00:27:21,230 All right. 359 00:27:21,270 --> 00:27:28,110 And then the active status snow remember that these column was what I would do whatever the column name 360 00:27:28,200 --> 00:27:31,310 is is what will be used as a column name for the grid. 361 00:27:31,410 --> 00:27:37,040 So I don't want to use a name looking like that and you know name and what is name. 362 00:27:37,050 --> 00:27:39,340 Name doesn't mean anything to an end user. 363 00:27:39,330 --> 00:27:47,500 So I renamed the columns so I said whatever column has user name as the name set it to use a name name 364 00:27:47,550 --> 00:27:50,490 should be rule name is active should be active. 365 00:27:50,700 --> 00:27:56,460 And then we set the idea visibility to falls. 366 00:27:56,460 --> 00:27:57,330 All right. 367 00:27:57,420 --> 00:28:05,520 And then what I also did was I modified the constructor for the add user so when we click add user I'm 368 00:28:05,520 --> 00:28:11,760 parsing in an object of this and this being the manage users form. 369 00:28:11,830 --> 00:28:12,550 Right. 370 00:28:12,600 --> 00:28:15,370 And then I didn't bother to do to construct. 371 00:28:15,400 --> 00:28:18,210 So sometimes I did tools sometimes I did one. 372 00:28:18,310 --> 00:28:19,410 So that did too. 373 00:28:19,410 --> 00:28:21,720 Now the user you know one off of them. 374 00:28:21,720 --> 00:28:26,790 So this time only did one because really and truly I don't think I'll be calling the ad user window 375 00:28:26,960 --> 00:28:29,590 we vote on object off money users. 376 00:28:29,670 --> 00:28:33,790 So you know you can mix and match it's up to you to determine what you may or may not need to do. 377 00:28:33,800 --> 00:28:41,850 So I just modify the existing constructor to have the parameters of manage users and declared the private 378 00:28:41,880 --> 00:28:47,310 object the private property sorry of moneys users initialized it here. 379 00:28:47,340 --> 00:28:48,770 And so that's allowed me no. 380 00:28:48,780 --> 00:28:58,020 After clicking submit to call on the populates grid function in the manage user's window. 381 00:28:58,020 --> 00:28:58,430 All right. 382 00:28:58,440 --> 00:29:03,330 So on so you click submit and it does all of the change it has to do to the database. 383 00:29:03,600 --> 00:29:09,670 We showed the success message and then we refresh the grid and then we close this window. 384 00:29:09,720 --> 00:29:10,620 All right. 385 00:29:10,620 --> 00:29:20,190 And then I also call this populates grid for in manage users and manage users remember we add two other 386 00:29:20,190 --> 00:29:24,580 buttons we had our reset password reset and we had the deactivate. 387 00:29:24,600 --> 00:29:29,370 So the activity more than the bastard reset would need to refresh because for a change of the active 388 00:29:29,370 --> 00:29:35,550 status then that's visible data changing because we have these active columns showing true or false. 389 00:29:35,550 --> 00:29:39,230 So we need to refresh each time that is done. 390 00:29:39,360 --> 00:29:45,270 And then I need to wire up this refresh button doesn't make sense we have 10 it doesn't work. 391 00:29:45,270 --> 00:29:50,400 So let me just add the Click event to the refresh button and this refresh button is just going to see 392 00:29:50,640 --> 00:29:51,990 populate grid. 393 00:29:51,990 --> 00:29:52,650 All right. 394 00:29:52,740 --> 00:29:55,140 So let's just look at this application. 395 00:29:55,700 --> 00:29:56,130 All right. 396 00:29:56,130 --> 00:30:00,830 So we opened up log then go to Monday's users so that's what our grid will look like. 397 00:30:00,830 --> 00:30:05,220 So we have our test user notice I'm not showing the password of course right. 398 00:30:05,220 --> 00:30:09,160 I mean it doesn't make sense to show the password this user. 399 00:30:09,180 --> 00:30:14,100 Remember this was the first user we created and we didn't set the rules so that's going to be blank. 400 00:30:14,100 --> 00:30:20,250 So I can actually just choose this one for the activations of me just click admin one and try this deactivate 401 00:30:20,290 --> 00:30:28,410 the admin ones octu status has changed and then we see that it changes to forms there refreshes the 402 00:30:28,410 --> 00:30:29,870 grid and it changes the falls. 403 00:30:29,880 --> 00:30:30,440 Right. 404 00:30:30,480 --> 00:30:35,530 So of course the grid doesn't look all that attractive with all this green space you can resize does 405 00:30:35,570 --> 00:30:37,310 not want to prioritize those things. 406 00:30:37,380 --> 00:30:41,550 I just want us to get the functional stuff under our hands right. 407 00:30:41,940 --> 00:30:47,640 And so let me just creates one more user and then I'm just going to call this user Clark and this person 408 00:30:47,640 --> 00:30:51,930 is going to be a data entry clerk submit and then click all key. 409 00:30:52,110 --> 00:30:53,520 And then there we go. 410 00:30:53,520 --> 00:30:56,350 So the window closes and then the clerk is there. 411 00:30:56,430 --> 00:31:01,180 If I deactivate then the active status is no false. 412 00:31:01,190 --> 00:31:01,840 All right. 413 00:31:01,860 --> 00:31:03,550 And then just the same way if I click. 414 00:31:03,570 --> 00:31:05,630 So if I. 415 00:31:05,680 --> 00:31:11,160 Well let me refresh and then if I try and click one of these you are going to get those because of the 416 00:31:11,160 --> 00:31:13,650 track catches it won't crash the program. 417 00:31:13,650 --> 00:31:14,380 Right. 418 00:31:14,520 --> 00:31:19,500 So those are the wonderful things that we have been able to accomplish with all of this. 419 00:31:19,500 --> 00:31:29,700 No let me just put in one final function and that is to check if the default password is the password 420 00:31:29,730 --> 00:31:31,980 being used when the user logs in. 421 00:31:32,730 --> 00:31:35,730 So there are a number of ways that this can be accomplished right. 422 00:31:35,760 --> 00:31:38,550 Pretty much the root of it. 423 00:31:38,550 --> 00:31:45,680 What we're checking is if the the password that the user used to get authenticated is equivalent to 424 00:31:45,680 --> 00:31:49,920 all we know is the default password. 425 00:31:49,920 --> 00:31:50,340 All right. 426 00:31:50,610 --> 00:31:58,860 So what I'm going to do is modify the main window load screen right so someone to have to create a new 427 00:31:59,010 --> 00:32:06,310 form and that will be like a password reset for which is really just to text boxes on a submit button. 428 00:32:06,630 --> 00:32:07,980 So I can just do that quickly. 429 00:32:08,130 --> 00:32:17,730 Go to solution explorer add a new farm and then this one is just going to be reset password. 430 00:32:17,760 --> 00:32:19,920 All right take add. 431 00:32:20,130 --> 00:32:28,080 And then you know we can draw regular cosmetic adjustments or reset password and what I'm going to let 432 00:32:28,080 --> 00:32:34,120 this one do really is it's going to be a very small window. 433 00:32:34,140 --> 00:32:37,500 Our guest went out to labels and to text boxes. 434 00:32:37,560 --> 00:32:43,080 All right so I just designed it off screen you can pause and design here is also what have two labels 435 00:32:43,080 --> 00:32:50,580 one to say enter a new password one to say confirm password and then the two text boxes for either which 436 00:32:50,580 --> 00:32:57,960 I renamed TB password and TB confirm password and then my button which I call B.T. and reset. 437 00:32:57,990 --> 00:33:03,510 So when I don't click this well this form is going to have to talk to the database I'm going to have 438 00:33:03,510 --> 00:33:07,110 to do my initialization as usual. 439 00:33:07,110 --> 00:33:07,890 All right. 440 00:33:07,890 --> 00:33:14,430 And then know that I have made a reference to my DB object what I'm going to have to do is retrieve 441 00:33:14,460 --> 00:33:20,520 the user changed the password part and then see if the changes. 442 00:33:20,540 --> 00:33:25,560 So if I'm going to need access to the user that should be modified then I went off to take it in as 443 00:33:25,560 --> 00:33:26,390 a parameter. 444 00:33:26,390 --> 00:33:39,130 Some would say user user and then I'll have my local so that's private user and then see the underscore 445 00:33:39,130 --> 00:33:48,940 user and then initialize on the score users of the value of the user being passed in as a parameter. 446 00:33:48,940 --> 00:33:50,000 All right. 447 00:33:50,050 --> 00:33:50,830 And then. 448 00:33:51,370 --> 00:33:51,640 All right. 449 00:33:51,640 --> 00:33:55,340 So we've done quite a bit of work on the reset password. 450 00:33:55,360 --> 00:34:00,440 I want to pause here and then I'm going to turn my focus again to the main windows so I'm just going 451 00:34:00,440 --> 00:34:04,300 to close off these tubs that I don't need. 452 00:34:04,300 --> 00:34:04,840 Right. 453 00:34:04,870 --> 00:34:05,470 No. 454 00:34:05,810 --> 00:34:07,880 All right. 455 00:34:07,960 --> 00:34:15,860 And then on the main window the main window in the load function. 456 00:34:16,120 --> 00:34:26,770 What I'm going to do is see that if the if the value of the user's hushed password is the same as the 457 00:34:26,770 --> 00:34:31,800 default attached password then the person needs to reset password. 458 00:34:31,800 --> 00:34:32,630 All right. 459 00:34:32,710 --> 00:34:39,670 So what I'm going to say here is so in the window Lord I'm just going to make some space here and I'm 460 00:34:39,670 --> 00:34:42,140 want to see. 461 00:34:42,410 --> 00:34:49,890 So what I'm going to see and know is if and then say something like user. 462 00:34:49,910 --> 00:34:52,300 So I have my user object here. 463 00:34:52,370 --> 00:34:54,330 User dot password. 464 00:34:54,360 --> 00:34:58,240 So I would already know the hushed password based on what's in the database. 465 00:34:58,460 --> 00:35:05,790 And then I want to say if that password that's in the database is equivalent to utilize dots. 466 00:35:05,910 --> 00:35:09,060 And then this would be default hashed password. 467 00:35:09,140 --> 00:35:09,700 See that. 468 00:35:10,190 --> 00:35:18,500 So I'm seeing if the password in the database is equivalent to the hushed password that is the default 469 00:35:18,500 --> 00:35:19,400 attached password. 470 00:35:19,410 --> 00:35:24,130 Remember this function is returning the hashed version of the default password. 471 00:35:24,170 --> 00:35:28,310 So anybody who's as positive as those reset are was just created. 472 00:35:28,310 --> 00:35:31,680 He's going to have whatever password this return. 473 00:35:31,850 --> 00:35:34,080 And that is what is going to be stored in their records. 474 00:35:34,110 --> 00:35:42,320 I'm saying if the user who is just logged in has the same password as the default hash password then 475 00:35:42,800 --> 00:35:47,430 we need to launch window for a reset buzzer. 476 00:35:47,420 --> 00:35:59,100 So I to Survivor reset password is equal to a new instance of the reset password window right. 477 00:35:59,160 --> 00:36:01,560 And then this time I'm going to show dialog. 478 00:36:01,560 --> 00:36:04,740 I noticed that this is seeing reset password. 479 00:36:05,040 --> 00:36:12,120 So because I didn't create to constructor so it's expecting us to pass in some user object so that satisfies 480 00:36:12,120 --> 00:36:18,960 that and then I went to see say reset password and then this time went to show it does dialog server 481 00:36:18,970 --> 00:36:22,410 so that we we looked at all we can launch one window at a time. 482 00:36:22,410 --> 00:36:27,970 Sure dialog is an excellent way to make sure you can just close it just like that. 483 00:36:27,990 --> 00:36:28,500 Right. 484 00:36:29,130 --> 00:36:33,000 So we're seeing reset password Dodge showed dialog. 485 00:36:33,060 --> 00:36:33,830 Right. 486 00:36:33,840 --> 00:36:41,820 And then what will happen is that the expectation is that the user will use that reset password dialogue 487 00:36:42,000 --> 00:36:45,810 and actually change their password if they don't then that's a problem. 488 00:36:45,810 --> 00:36:53,290 But hey so when the window lords we do that check and then we display the reset password windows so 489 00:36:53,290 --> 00:36:59,850 no when they get that window then the expectation is that we one get when what. 490 00:36:59,910 --> 00:37:02,310 Well we're going to get the values that they entered. 491 00:37:02,310 --> 00:37:11,130 So that's the Save Our password is equal to and then we have TB password not text. 492 00:37:11,130 --> 00:37:12,680 All right. 493 00:37:12,750 --> 00:37:21,610 And then the next one is going to be TB confirmed puzzlers of are on firm on this score. 494 00:37:21,620 --> 00:37:31,930 Password is equal to TB confirm us word not text all right. 495 00:37:32,320 --> 00:37:34,710 And then first they'll want to compare them. 496 00:37:34,720 --> 00:37:42,610 So I'm going to see if this word is not equal to confirm passwords. 497 00:37:42,640 --> 00:37:44,320 So we know that that's a problem. 498 00:37:44,320 --> 00:37:48,850 If you use any modern web site you know that the password on the gun for impostor bodies must be the 499 00:37:48,850 --> 00:37:49,750 same. 500 00:37:49,750 --> 00:37:53,250 Then it's going to see a message box 501 00:37:56,180 --> 00:38:05,900 not sure our goal is going to warn the user that passwords will not much. 502 00:38:06,160 --> 00:38:08,440 Please try again. 503 00:38:08,440 --> 00:38:10,270 All right. 504 00:38:10,500 --> 00:38:21,890 And then otherwise we're going to nose say that or on the score User object dot password is equal to 505 00:38:22,490 --> 00:38:35,730 utilize dot hash password and then we're hashing whatever value they put in as the new password and 506 00:38:35,750 --> 00:38:46,580 then once we're done with that we can see on this score D.B. dot save changes because we have access 507 00:38:46,580 --> 00:38:51,130 to the actual objects coming from the database. 508 00:38:51,170 --> 00:38:52,810 So we're going to try that. 509 00:38:53,660 --> 00:38:56,190 This has worked for me in the past. 510 00:38:56,210 --> 00:38:57,920 I'm not going to say if it is going to work. 511 00:38:57,920 --> 00:39:00,170 No but I mean we're going to test it out. 512 00:39:00,170 --> 00:39:00,440 No. 513 00:39:00,440 --> 00:39:06,650 So let me start on that I'm going to log in with one of those new users that would obviously have one 514 00:39:06,650 --> 00:39:12,800 of those new passwords someone to log in as the clerk. 515 00:39:12,830 --> 00:39:13,810 So clerk. 516 00:39:14,120 --> 00:39:20,080 And it would be kept to be a little B or D I'd say one two three. 517 00:39:20,210 --> 00:39:22,140 That's the password that we set. 518 00:39:22,250 --> 00:39:27,440 And then we okayed studying this that those are invalid. 519 00:39:27,440 --> 00:39:31,180 It's telling us it's invalid because this user is set to inactive virus. 520 00:39:31,190 --> 00:39:32,420 So at least something works. 521 00:39:32,420 --> 00:39:34,490 So the clerk on the password. 522 00:39:34,490 --> 00:39:36,400 But the user is inactive. 523 00:39:36,410 --> 00:39:37,250 So that didn't work. 524 00:39:37,280 --> 00:39:42,400 So let's try a test user instead someone to do test user. 525 00:39:42,410 --> 00:39:47,960 And I'm going to type it in lowercase because in the in the actual database so it does mixed case. 526 00:39:47,960 --> 00:39:48,970 So let me see if it works. 527 00:39:49,000 --> 00:39:49,380 OK. 528 00:39:49,400 --> 00:39:50,290 Does work. 529 00:39:50,300 --> 00:39:54,170 And then they're telling me that I have to enter a new password. 530 00:39:54,170 --> 00:39:54,710 Right. 531 00:39:54,780 --> 00:40:00,110 So I'm going to change this password to the same word test user. 532 00:40:00,110 --> 00:40:00,430 All right. 533 00:40:00,420 --> 00:40:05,630 So we need to fix that because I didn't set the password char on the password and confirm password. 534 00:40:05,930 --> 00:40:11,570 But let's try the reset password nonetheless All right. 535 00:40:11,560 --> 00:40:13,670 So I noticed that it's and it does not work. 536 00:40:13,680 --> 00:40:17,820 And I mean that's that's what I was fearful of. 537 00:40:17,820 --> 00:40:18,610 To be honest. 538 00:40:18,610 --> 00:40:25,280 But it's not a surprise to me when we can see whether that's some cozy house bit of work to do still. 539 00:40:25,290 --> 00:40:29,930 So what happens is that even though the user object is passed over. 540 00:40:30,000 --> 00:40:35,100 We're not we're technically not connected to the database by the time we hit this point right. 541 00:40:35,100 --> 00:40:40,590 So we can't just DBC if changes because technically there were no changes made to the database. 542 00:40:40,590 --> 00:40:41,070 All right. 543 00:40:41,400 --> 00:40:42,960 So what's I'm going to do. 544 00:40:42,960 --> 00:40:47,730 I'm going to exit debug mode and then we'll just make some final touches. 545 00:40:47,730 --> 00:40:54,540 So first them setting the password char for my ticks boxes and so my password char here is going to 546 00:40:54,540 --> 00:41:02,070 be asterisk for both of them so that you know we don't see the plain text when the person's typing in 547 00:41:02,070 --> 00:41:02,850 their password. 548 00:41:02,880 --> 00:41:04,310 So that's one. 549 00:41:04,800 --> 00:41:11,780 Secondly what I'm going to have to do is still retrieve the actual user from the database right. 550 00:41:11,790 --> 00:41:19,420 So I'm going to have to say var user notice not underscore user this time just user is equal to be a 551 00:41:19,470 --> 00:41:32,250 dot and say users dot first or default and then lambda expression where I say cue arrow and then cue 552 00:41:32,250 --> 00:41:41,090 Dot and I just want where that I'd be in the database matches that I.D. that is in my current user object. 553 00:41:41,100 --> 00:41:41,520 Right. 554 00:41:42,180 --> 00:41:44,850 So are those too much I want by that user. 555 00:41:44,850 --> 00:41:50,370 And then I would say that this user that I just retrieved to the database so the connected to the database 556 00:41:50,370 --> 00:41:56,450 here I'm seeing set that use it that I just retrieve to have the new password and then see if that change 557 00:41:56,450 --> 00:41:57,420 is right. 558 00:41:57,420 --> 00:41:59,750 Of course we want to as is you. 559 00:41:59,940 --> 00:42:03,530 As is customary grab all of that instead of I try to catch. 560 00:42:03,570 --> 00:42:04,200 Right try. 561 00:42:04,210 --> 00:42:11,250 Try tab twice and then we're trying that operation I mean once that operation is successful we show 562 00:42:11,250 --> 00:42:21,630 a message box to see that the password was reset successfully. 563 00:42:21,870 --> 00:42:28,420 Of course you don't want to just print Sprint what the password was was so positive was reset success 564 00:42:28,490 --> 00:42:30,590 fully. 565 00:42:30,630 --> 00:42:31,140 All right. 566 00:42:31,140 --> 00:42:39,520 And then after that we can close the password reset window and then if there is an exception I don't 567 00:42:39,520 --> 00:42:40,350 want to throw. 568 00:42:40,360 --> 00:42:50,950 But I will show our message boxing that there is an Arab peace Dragon an arrow has occurred. 569 00:42:50,960 --> 00:42:53,450 Please try again. 570 00:42:53,450 --> 00:42:55,010 All right. 571 00:42:55,310 --> 00:42:59,720 And so we should have more success this time our own. 572 00:42:59,720 --> 00:43:09,850 So let's try that again someone to log in with test user and the password is kept up the password. 573 00:43:09,860 --> 00:43:17,720 W R D sign one two three log in and then it's going to process process process and then it's going to 574 00:43:17,720 --> 00:43:27,470 tell me I need to reset my password so then I'm going to retype test user as the password reset password. 575 00:43:27,480 --> 00:43:29,400 It was reset successfully. 576 00:43:29,430 --> 00:43:29,990 Okay. 577 00:43:29,990 --> 00:43:35,430 And then we move on some logged in as this user as you can see it on their test user is not an admin 578 00:43:35,430 --> 00:43:41,430 so I don't have Monday's users and then I can go ahead and proceed and do anything else that the test 579 00:43:41,460 --> 00:43:44,290 user is permitted to do. 580 00:43:44,370 --> 00:43:53,340 And so that's a nice way to you know modify how we one view and interact with users how we check if 581 00:43:53,340 --> 00:43:59,610 they have the default password or not and modify how their log in experience will look there are still 582 00:43:59,610 --> 00:44:05,550 some gaps and I would like for you to fix those gaps and let me know what those gaps are so fully. 583 00:44:05,550 --> 00:44:07,260 Can one identify them. 584 00:44:07,260 --> 00:44:12,420 Because I know what they are is just that if I was to teach every single one of them then this video 585 00:44:12,420 --> 00:44:13,470 would never end. 586 00:44:13,560 --> 00:44:20,610 But I want you to identify those gaps and then let me know that you think these are gaps and then let 587 00:44:20,610 --> 00:44:23,270 me know how you think we could go about fixing them. 588 00:44:23,430 --> 00:44:29,640 And then you know we could work from there but for now that's all we can manage users and.