<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class=""></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div class="gmail_extra">Hi Andrew, <br><br>So I end up with something like this?<br></div><span class=""><br>get '/reset/:token' => sub {<br><br></span>    return template 'passreset' => {<br>    <br>    my $input_hash {<br>        <br>    token => params->{token}<br>  <br>    }<br><br>    } # end of return<br><br>    # compare against stored tokens<br>    my ($matched_user_id) = User->lookup_tokens($input_hash->{token});<br><br>    if ($user_id < 1) { # does not match<br><br>         halt("Unauthorized");<br>    <br>    }<br>                    <br>     # token matches that of user no 349.<br>  <br>    session mathced_user_id => $matched_user_id; <br>                    <br>};<span class=""><br></span><br></div></div></div></blockquote></div><br></div><div class="gmail_extra">For the sake of Dancer2 posterity I should mention that I believe that my problem was caused by the fact that I was trying to capture the variable after the return. As Andy Beverly was kind enough to explain to me, once you return you return and the rest of the block of code is not executed. Capturing the variable -- in ways that all of your rightly suggested -- before the return solved my problem. I think I should also mention that D2 Auth::Extensible now takes care of all of this password reset business.  So anyone wanting to deal with the pain that is a "password reset system" should look into it.<br></div></div>