<div dir="ltr"><div><div><br><div class="gmail_extra"><br><div class="gmail_quote">2015-09-17 4:44 GMT-05:00 Andrew Solomon <span dir="ltr"><<a href="mailto:andrew@geekuni.com" target="_blank">andrew@geekuni.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_extra">Hi Richard,<div><br></div><div>[Without knowing the full state diagram of the site you're setting up I'm not sure I'm really answering your question, however...]</div><div><br></div><div>What I can say is that when you send someone an email with a link to click, the corresponding GET route handler should *not* be assuming there's a session for that user since the web server's session cache may have been cleared before they respond to the email.</div><div><br></div><div>If you want the token attached to the user so that when they click on the link you know who's visiting, you should store the token in your database against the user's account.</div><div><br></div><div>Does that answer your question?</div><span class=""><font color="#888888"><div><br></div><div>Andrew</div></font></span><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br></div></blockquote></div></div></blockquote></div><br></div><div class="gmail_extra">Hi Andrew, <br><br>So I end up with something like this?<br></div><br>get '/reset/:token' => sub {<br><br>    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>};<br><br><br>post '/reset/:token' => sub {<br><br>    my $matched_userid;<br><br>    if (! (defined session 'matched_user_id')) {<br><br></div>     # not supposed to be here<br></div>      redirect "/";<br><div><div> <br></div><div>    } else {<br><br>        $matched_userid =  session 'matched_user_id';<br>}<br></div><div>    <br>   my $input_hash = {  <br>       <br>       Psw1 => param('password1'),<br>       Psw2 => param('password2'),<br>       <br>   }; <br>   <br>   # make sure passwords match eachother<br><br>   # update password for user $matched_userid; <br>   <br>    <br>};<br><br><br></div></div></div>