So we have our sinor package written, and last time when I was talking about this final function expired,
you may have noticed I got my true and false reversed when something has expired.
This will return true.
When something has not expired, it returns false.
And that should be pretty clear right from the name of the function.
And that was my mistake.
But in any case, let's go over to our handlers, dash API and use this package.
So the first thing we want to do.
Is right here after we pass the juice and we need to create a valid Eurail that we can then sign now,
of course, this URL doesn't exist yet, so we haven't written the logic on the front end to display
the page, but we'll take care of that before too long.
So let's create a variable, which I'm going to click.
And link is a sign the value of format dot s print F and the string I want to format is starts with
the percent s which will be the euro for our front end then slash reset dash password email equals percent
s.
And the first substitution is our you url to our front end.
We get that from the config config front end and the second one is the email and we get that from payload
email.
So the URL will be in my case HTP column slash localhost part four thousand reset dash password questionmark.
Email equals whatever email is taken to the form.
OK, now we need to sign this and here's where we use our package and I'll just say sign.
That's a variable is a sign the value of Eurail Sinar.
Hopefully, that is the important for me.
Dart Center.
Right there, and I just populate that with my secret,
which is Casta to a slice of bytes, I've got confect secret key.
OK, so it looks like it didn't do the import for me well, for the quick fix will do it.
Yes, and important.
So now we have a variable we can use to call those three functions we just created, and of course,
what I want to do here is create a sign link.
So signed link
is assigned the value of sign dot, generate token from string, and I hand it by link, but I created
right up here in line for twenty three, so this should hand back a signed Yoro.
So the next thing I have to do is get rid of this hardcoded Yoro and make that the sign link.
OK, the only other thing I want to do at this point is people can type whatever they want but at an
all right here that's not going to work email.
The only other thing I need to do at this point is people can enter whatever email address they want
on the front end.
And I need to make sure that I actually have that user before I send the information back, before I
send my JSON back.
So after I do my read JSON and before I try to generate my link, let's just verify that the email verified
that email exists.
OK, so we can do that really easily.
I'll ignore the first response because I don't actually care about the user.
I just want to see if the user exists in my database.
So ignoring the first return value but looking for an error.
Let's call app dot get or debug get user by email and put in.
Payload email, if error is not equal to nil.
That means we can't find that email, so I'll just send a response via RESP is a struct and it has an
error field, which is a boolean.
And Jason, I'll call that error and it has a message.
Which is also a bully and and Jason
will call that message, and our populated values rest on error equals true because there is an error
and resp message equals no matching email found on our system.
And that should be a straight.
And we just write that, Jason, and return so aptly, right, Jason?
And that requires some kind of status and status accepted because I accepted it, but I'm not going
to do anything with it.
And our response in return.
OK, so if everything went according to plan, I should be able to run this.
Let's give it a try.
So make start.
I'll just start everything.
It all compiled, that's good.
Let's go back to our Web browser forgot password, so I'm going to put in me at here dot com, which
doesn't exist.
Let's see if we got it right.
No matching email found in our system perfect.
Now let's put in admin at example dot com, which is in our system.
And it's centered let's go to Mail Trap and see what we get.
So we have one here and there it is, click on the link below to get started and it gives me HDP localhost
four thousand reset dash password questionmark email equals admitted example dotcom followed by an ampersand.
Then here's the part that signs this link.
It's a signed you URL hash equals all of this.
Now we obviously can what we can click on that, but we'll just get a page not found or some kind of
response like that.
We need to next go create the URL on our front end to look for reset, dash password and then validate
the signature for that URL and do something if it's valid and do something else if it's not.
And we'll get started on that in the next lecture.