[dancer-users] route handler for a URL that matches a token

Richard Reina gatorreina at gmail.com
Thu Sep 17 01:16:15 BST 2015


2015-09-16 16:46 GMT-05:00 Andrew Solomon <andrew at 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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150916/03bda3c2/attachment.html>


More information about the dancer-users mailing list