So what we want to do this time is to create a helper function that allows us to notify the user by
sending back adjacent file that says invalid credentials.
And that's pretty straightforward.
So let's go over to help restart go and I'll just scroll to the bottom of this file and create a new
function which will have the receiver of app on your application and we'll just call it invalid credentials.
And the only thing we really need to pass it is our response rate or something to write to.
So easy to beat up response writer and potentially an error setback.
So let's create a payload for our payload and it will be a struct and it will have error as one member,
which will be a pool and andriessen, we'll call this error and then we'll have a message, which is
a string and adjacent we call that a message.
And we'll populate this payload error as equal to true
and payload, that message is equal to invalid authentication credentials
or something like that.
So once we have that populated, that variable is now populated, really, which you can just call app
DOT.
Right, Jason?
And we're going to hand it our response.
Right.
And we're going to hand it the status we want.
In this case, it's going to be htp dot status, unauthorized enter payload and we'll just return the.
Now, Abdul, right, Jason actually returns potentially an error, so we should actually check for
an error.
Error is a sign the value of the affair is not equal to nil.
Return the error there.
So now we have this available to us so we can go back to Handler's API, go for Henders Dash API, Dongo,
and we'll send back our invalid credentials, abdon invalid credentials.
And all it needs is a response writer.
And of course, we return at this point because we don't want to go any further.
So now we have our user by email, assuming we get past this error check.
So we have our our our user and now we want to validate the password.
So, of course, again, this is the sort of thing we might be doing more often than not.
And what we're going to do is compare the hash in the database to whatever password they've given us.
And again, I'm not going to put that right in this method, in this function.
Instead, we'll go back and create a helper function called something like password matches, and that
will do the validation for us.
So we'll take care of that in the next lecture.