hi s,

On Wed, Nov 26, 2014 at 10:47 AM, [email protected] <[email protected]> wrote:
> Your code contains a bug. You have declared $smscode in the global scope, so
> every new request will change it for whole application (and all other
> requests). It will not work in morbo too, try to do what you want in
> different browsers at the same time.

indeed.

> It worked for you with morbo by accident but not with hypnotoad because
> hypnotoad is preforking server, so while one request can be handled with one
> instance of your application, while another can be executed with another
> process (and another $smscode global variable, undefined by default)
>
> Try to store your secret data in Mojo's sessions
> http://mojolicio.us/perldoc/Mojolicious/Sessions and avoid any global
> variables

So now I have no $smscode/$random global vars. I do this instead:

post '/' => sub {
    my $c        = shift;
    my $random_string = _generate_random_string(6);
    _sendemail($random_string, $mobile);
    $c->stash( mobile => $mobile );
    $c->session( random => $random_string );
    $c->render('smsform');
};

post '/smscode' => sub {
    my $c = shift;
    $c->session( smscode => $c->param('smscode') );
    $c->render('smscode');
};

__DATA__

@@smscode.html.ep
% layout 'default';
%= session 'smscode'
%= session 'random'

and that works. I can see both values displayed. But how can I compare
those two values?

I try this in the template:

@@smscode.html.ep
% layout 'default';
%= session 'smscode'
%= session 'random'

% if ( session 'smscode' eq session 'random' ) {
    <%= form_for '/changepass' => (method => 'post') => begin %>
        Old Password:
        <%= input_tag 'old', type => 'password' %>
    <br>
        New Password:
        <%= input_tag 'new', type => 'password' %>
    <br>
    <%= submit_button %>
    <% end %>
% }

But the form is not displayed. I am obviously doing something wrong :-)

Thanks for any hints.

-- 
regards,
Natxo

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to