2015-09-16 16:46 GMT-05:00 Andrew Solomon <andrew@geekuni.com>:
Hi Richard
Firstly with the GET request when you click on this
http://myapp.com/reset/JiOk49ld9oekdisJkflSS3ed <http://myapp.com/resetJiOk49ld9oekdisJkflSS3ed>
your route handler will be something like this (note ':' instead of '$'):
get '/reset/:token' => sub {
return template 'pass_reset' => { token => params->{token} };
};
This template views/pass_reset.tt will contain something like
<form action="/reset/[% token %]" method="post"> <input type="password" name="password1"><br/> <input type="password" name="password2"><br/> <input type="submit" value="Submit"> </form>
and back in the controller on clicking submit, it will be handled by
post '/reset/:token' => sub {
# do something to check params->{password1} eq params->{password2} ...
};
(Please imagine the code above is scribbled on a blackboard - I haven't run it:)
Andrew
Hi Andrew, Thank you for the reply. For the value of token in the url '/reset/:token' do I first set the value of token with my $token = get_token(); # subroutine that returns generated token session username => $token; so that it matches the urlJiOk49ld9oekdisJkflSS3ed <http://myapp.com/resetJiOk49ld9oekdisJkflSS3ed> link that was sent to the user in the email?