So we have a good start on the show reset password handler, we can ensure that the URL is not been
tampered with, but obviously we need to at least show the reset password page and allow the user reset
the password.
So let's get started doing that.
And it's going to take a little while, but let's get started.
So the very first thing I'll do is change this to a not if not valid, get rid of the L's.
And all I'm going to do right now is just print an error message to the log after error log print line
and I'll just put in a valid URL tampering detected and I'll return.
Now, that's not very friendly and obviously you can do whatever you want here.
Redirect the user to another page, display an error message, whatever it may be.
But assuming we get past that, we actually now need to render a template.
So the first thing I'll do, I know I'm going to want the email address in that form I displayed.
OK, so I'll create a data variable, which is make a map string and then interface so I can store whatever
I want in there and I'll put in data email.
And that will be equal to the actual email, which is from our URL dot query yet.
And we called it email.
So that grabs it from the query parameters.
Now render a template and I can just use this right here as a starting point.
So I copy and paste it down here and change that to reset password which doesn't exist but were created
a minute and I'll populate the data template with data equal to data.
OK, so now we're going to be rendering a reset password page, which means we need the template.
So let's go over to our templates folder, create a new file which I'll call reset password page go
HTML.
And just to say some time, I'll simply copy the forgot password page, because it'll be very similar
to this and paste that in here and we'll make some changes.
So to start with, this becomes reset password.
And down here, we want this to be reset password
and down here will change the button to reset password.
Now, this will be password and the type is going to be password.
And I'll copy paste it in the four label, make the ID and the name equal to password and autocomplete
will become password.
No.
Then I'll just duplicate this entire thing
and give them a place to verify.
So verify a password and this becomes verified.
Dasch password copied and pasted in here, pasted in here and paste it in here and everything else for
that should stay pretty much the same.
So now we'll come down to this bit.
Show is fine.
We already have the messages because we copied it, so that's fine.
We'll change this to password reset.
And up here, what do we call the form, let's change it from forgot form to present form copy.
And this didn't work very well and should be reset for there, OK?
And it looks like on the login form, that's probably the same thing, but I'll change that later on.
OK, so down here, let's get down to this and we'll say document get an element, the ID reset form.
And after this, before we go any further, let's make sure that we actually have.
So whatever the type in the password field should match what they typed in the password field or verify
password field.
So we'll just put some logic in here.
If document doesn't get element by ID and your password, if its value is not exactly equal to document
douget element by ID, and we called it verify password value and we'll show it to.
Show error and his words do not match and we don't want to go any further, so we'll return.
OK, so let's try this out.
Let's go to our make sure everything is stopped.
Make start back.
And I'll run here.
So let's go back to our Web browser and clear the JavaScript console and let's start the whole process.
So forgot password.
My email is admin at example dot com,
and that should send the link and we go to mail drop and there it is.
And let's click on this.
And there it is, reset password.
OK, so the form is displaying properly.
Now, obviously, there's a few more things to do.
We haven't actually called the back end to change the password.
So we'll have to implement that logic, which means we'll need to set up a root on the back end and
take care of the actual resetting of the password.
But this is a good start.
So one last thing before I forget, let's go back to the ID.
And let's how terminal and let's find Handler's API and make sure that we're actually going to send
the send to the correct email address.
So this should actually be payload email, because the second parameter, I think is the two.
Yes, second is two.
So that will allow us to actually send the email to the correct individual.
And I was just an oversight on my part.
So in the next lecture, we'll go back to our reset password page.
And we have some work to do down here because we're not going to forgot password.
We need to set up a different route and actually initiate the password reset.
So we'll get started on that in the next lecture.