So we have our front end written for sending messages, we have our back hand written for sending messages,
and we're not sure it's all right yet, but we can test that.
First thing we have to do before we test it is actually populate these two templates, password reset,
HTML template and password reset plain TMB.
Let's start with the HTML one.
So this is a standard template, so we need to define what I'm going to define here is body OK?
And that is what I want to use
back here in Maila, Dongo, when I specify the body on this line.
Twenty six, that's the part I'm executing.
I'm looking for that in the template and the same thing down here on line forty one.
So back in our password reset html, we just defined the HTML for an email.
So DOCTYPE.
And that's going to be tomorrow, and we need our opening HTML tag and our closing HTML tag.
And we also need a head section and a closing head section.
And in the head, I'm going to put in two metal tags.
Not a name equals viewport.
And the content of that tag is equal to width equals device dash width, and the second one is metter
htp dash equiv.
Equals content, dash type content equals text HTML, followed by a semicolon and a space, and shaza
equals UTF Dash eight like that, and then close that time and we probably should close it this way
as well, because male clients aren't that smart.
So that's our head.
Now the actual body has an opening in a closing section.
Body.
And we're going to say in here, just a paragraph to say hello and closing paragraph two and a paragraph
teg, you recently requested a link to reset your password and close this paragraph and then click on
the link below
to get started and close the paragraph to another paragraph tag and the link traffic equals and hear
inside quotation marks.
I'll use the link we specified in our handler that we added to the data we're passing to this template.
So that's the link.
Then we'll print out the link again so they can have something to see and click on and close our.
And down here, I'll just put another paragraph, dash, dash and a paragraph just to be our.
Widgets, coat and clothes.
OK, so that's the HTML version of our email.
Now let's do the plain version of our emails open password reset plain and it's very similar, but of
course it's plain text.
We still have to define body.
And closer and in between, we just say hello and you'll notice and not indenting this, because this
is plain text email.
You recently requested a link to reset your password, blank line, visit the link below to get started.
Then the link, and I'm not going to wrap it in a because this is not HTML and then just widgets code
and I'll put two dashes in front of it because people expect to see that.
OK, so there are two HTML and plain text templates.
So now we can actually try this.
Someone opened my terminal, make sure everything is stopped.
Make stop.
Make start.
They're all compiled.
Let's see what we got wrong, so back to our Web browser and refresh this page, send the reset validation
worked so me and here dot com and again, it doesn't really matter what it is.
I'll open the JavaScript terminal to see if we get any kind of response.
And send password reset link.
So unexpected end of data in line one of column one of the Jason data, so we obviously forgot something.
Let's go back and see what we did wrong.
So no error messages here.
So let's go look at the handlers.
So to make sure I'm getting to the right place, I'm going to reach API.
And I'm looking at apps for password, so let's look at our actual template, which is called password
reset or something like that, forgot password and see if we're going to apply for a password.
That's the first thing to verify.
So when the JavaScript for this, I am going to slash apps forgot password, so that's not it.
So let's go back to our roots.
Roots API.
And now let's look at the handler app to send a password reset.
OK.
Oh, we didn't actually call the function to send the email.
Well, that was silly.
So we actually need to send the email that's as simple as error equals.
And we're going to call app dot sendmail right there.
And it requires the first thing, InFocus widgets, dot com.
The second thing, I use the same email address because it's just a test info widgets, dot com
and a subject password reset request.
And the name of the template I want, which is password dash reset with nothing after it because we
append the HTML template and plain duct tape to it and then data.
Now we'll check for an error.
If error is not equal to nil, then I'll say APTA error log, print line, print the error and I'll
send a bad request after and request.
And that requires are in the air and I'll return, so we send the message, we get past that there's
no air.
Now we need to send our response.
So I'll save our rasp is a struct and I'll populate error rule.
And in JSON, we call that error and the message is a string.
And in Jason, we'll call that message, which is what we're looking for on the front end and right
this apter.
Right, Jason, you have to populate that variable.
All right, Jason, HGP status created, which is a good one for this case and a response our data.
And let's just populate this and all we really need is the the bullier.
So respeto error equals false.
OK, let's stop this.
Make stop start.
See if it compiles.
Perfect.
Let's go back to our Web browser, reload this page, clear the JavaScript console, put in any email
address, Nehad here, dot com, and try sending the password link again.
Messages is not.
So I have a typo somewhere on that page.
So actually look and see what they're looking for, I suspect it's just the ID.
So messages.
And I left logging messages there.
OK, so we'll go fix that.
That's an easy one.
So back to forgot password and my error is pretty simple up here.
I'm saying let messages equal document get element by the log in messages, but I actually called it
messages I think will verify that in a second.
Let's go up here.
And I called it messages.
OK, so third third time's a charm.
So make it stop.
Make start.
And give myself some blank lines, go back to my Web browser, reload this, go to the console, clear
the console me at here dot com, send password, reset.
OK, we got no air.
Now let's go look at our mail trap and chances are we're going to have to in there because I think that
message went and then I got a JavaScript error afterwards.
But let's go find it in mail trapped.
I have two messages, one here.
And that looks right.
And that's the link I specified and one here that looks right.
And that is a good start.
But of course, we don't actually have a reset password link.
I'm just going to some university's Web site, and we have no logic in place to actually change the
user's password, to give them access to a page that allows them to type in their new password twice
and update their password in the database.
So we'll get started on that in the next lecture.