WEBVTT 00:02.310 --> 00:07.830 So what we want to do this time is to create a helper function that allows us to notify the user by 00:07.830 --> 00:10.910 sending back adjacent file that says invalid credentials. 00:10.920 --> 00:11.970 And that's pretty straightforward. 00:12.000 --> 00:17.820 So let's go over to help restart go and I'll just scroll to the bottom of this file and create a new 00:17.820 --> 00:26.900 function which will have the receiver of app on your application and we'll just call it invalid credentials. 00:27.510 --> 00:31.520 And the only thing we really need to pass it is our response rate or something to write to. 00:31.980 --> 00:37.260 So easy to beat up response writer and potentially an error setback. 00:39.840 --> 00:48.000 So let's create a payload for our payload and it will be a struct and it will have error as one member, 00:48.330 --> 00:58.770 which will be a pool and andriessen, we'll call this error and then we'll have a message, which is 00:58.770 --> 01:01.680 a string and adjacent we call that a message. 01:04.630 --> 01:09.310 And we'll populate this payload error as equal to true 01:11.980 --> 01:19.210 and payload, that message is equal to invalid authentication credentials 01:22.390 --> 01:23.120 or something like that. 01:23.950 --> 01:28.960 So once we have that populated, that variable is now populated, really, which you can just call app 01:28.960 --> 01:29.220 DOT. 01:29.230 --> 01:29.880 Right, Jason? 01:31.540 --> 01:33.460 And we're going to hand it our response. 01:33.460 --> 01:33.640 Right. 01:34.030 --> 01:35.790 And we're going to hand it the status we want. 01:35.800 --> 01:46.150 In this case, it's going to be htp dot status, unauthorized enter payload and we'll just return the. 01:51.790 --> 01:57.040 Now, Abdul, right, Jason actually returns potentially an error, so we should actually check for 01:57.040 --> 01:57.370 an error. 01:57.640 --> 02:03.820 Error is a sign the value of the affair is not equal to nil. 02:06.340 --> 02:07.990 Return the error there. 02:08.770 --> 02:16.210 So now we have this available to us so we can go back to Handler's API, go for Henders Dash API, Dongo, 02:17.950 --> 02:24.280 and we'll send back our invalid credentials, abdon invalid credentials. 02:24.430 --> 02:26.110 And all it needs is a response writer. 02:26.230 --> 02:29.120 And of course, we return at this point because we don't want to go any further. 02:30.370 --> 02:34.960 So now we have our user by email, assuming we get past this error check. 02:34.990 --> 02:39.570 So we have our our our user and now we want to validate the password. 02:39.700 --> 02:44.800 So, of course, again, this is the sort of thing we might be doing more often than not. 02:44.800 --> 02:50.090 And what we're going to do is compare the hash in the database to whatever password they've given us. 02:50.500 --> 02:54.590 And again, I'm not going to put that right in this method, in this function. 02:54.820 --> 03:01.270 Instead, we'll go back and create a helper function called something like password matches, and that 03:01.270 --> 03:02.490 will do the validation for us. 03:02.800 --> 03:05.470 So we'll take care of that in the next lecture.