Discussion:
Couple probelms with the "growing" tut form the Docs.
(too old to reply)
Ray Sleeper
2014-08-02 23:42:56 UTC
Permalink
I'm getting an error for the 'check password' part of the tut:
*Can't locate object method "check" via package "Mojolicious::Lite" at
myapp.pl*

I get the same for 'method secret' part as well
Here are the offending codes:

app->secrets(['Mojolicious rocks']);



return $c->render unless $c->users->check($user, $pass);

I can post all the code, but it's exactly the same as in the tutorial.
Any insight would be appreciated.

btw I am brand new to Mojolicious, but I have some experience in perl.
--
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
sri
2014-08-02 23:58:23 UTC
Permalink
Post by Ray Sleeper
I can post all the code, but it's exactly the same as in the tutorial.
If it was, it would work.

--
sebastian
--
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Ray Sleeper
2014-08-03 00:02:35 UTC
Permalink
Thanks for the insight, that was really helpful.

A more constructive reply would have been to simply ask me to post all my
code.
Is that in fact what you are trying to say?
Post by Ray Sleeper
I can post all the code, but it's exactly the same as in the tutorial.
If it was, it would work.
--
sebastian
--
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
sri
2014-08-03 00:09:21 UTC
Permalink
Post by Ray Sleeper
Thanks for the insight, that was really helpful.
Please be nice, passive-aggressive beheavior is not welcome here.

--
sebastian
--
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Ray Sleeper
2014-08-03 00:15:26 UTC
Permalink
Here is the full code:

#!/usr/bin/env perl

use Mojolicious::Lite;
use lib 'lib';
use MyUsers;

app->secrets(['Mojolicious rocks']);

# Helper to lazy initialize and store our model object

helper users => sub { state $users = MyUsers=>new };

any '/' => sub {
my $c = shift;
# Querry parameters
my $user = $c->param('user') || '';
my $pass = $c->param('pass') || '';

# check password
return $c->render unless $c->users->check($user, $pass);

# Store username in session
$c->session(user => $user);
$c->flash(message => 'Thanks for logging in.');
# redirect to protected page with 302 respons
$c->redirect_to('protected');
} => 'index';

group {
under sub {
my $c = shift;
# redirect to main with 302 response if not logged in
return 1 if $c->session('user');
$c->redirect_to('index');
return undef;
};

#protected page
get '/protected';
};

#Logout
get '/logout' => sub {
my $c = shift;
$c->session(expires => 1);

#redirect to main with 302
$c->redirect_to('index');
};

app->start;

__DATA__

@@ index.html.ep
% layout 'default';
%= form_for index => begin
% if (param 'user' ) {
<b>Wrong name or password, plea try againm.</b><b>
% }

Name:<br>

%= text_field 'user'
<br>Password:<br>

%= submit_button 'Login'
% end

@@ protected.html.ep
% layout 'default';
% if (my $msg = flash 'message' ) {
<b><%= $msg %></b><br>
% }

Welcome <%= session 'user' %>.<br>

%= link_to Logout => 'logout'

@@ layouts/default.html.ep

<!DOCTYPE html>

<html>
<head><title>Login Manager</title></head>

<body><%= content %></body>
</html>
Post by Ray Sleeper
Thanks for the insight, that was really helpful.
Please be nice, passive-aggressive beheavior is not welcome here.
--
sebastian
--
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
rocko
2014-08-03 03:34:59 UTC
Permalink
BTW, I do have a 'check' sub in the 'MyUsers.pm' file.
Just in case anyone was wondering.
--
You received this message because you are subscribed to a topic in the
Google Groups "Mojolicious" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/mojolicious/WXVFOTEnghc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
--
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Dotan Dimet
2014-08-03 07:12:13 UTC
Permalink
<html style="direction: ltr;">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body style="direction: ltr;" bidimailui-charset-is-forced="true"
bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Shoudn't that be <code
class="prettyprint"><span style="color: #000;"
class="styled-by-prettify"></span><span style="color: #606;"
class="styled-by-prettify">MyUsers</span><span style="color:
#660;" class="styled-by-prettify">-&gt;</span><span
style="color: #008;" class="styled-by-prettify">new</span><span
style="color: #000;" class="styled-by-prettify"> ? You've got
</span></code><code class="prettyprint"><span style="color:
#000;" class="styled-by-prettify"></span><span style="color:
#606;" class="styled-by-prettify">MyUsers</span><span
style="color: #660;" class="styled-by-prettify">=&gt;</span><span
style="color: #008;" class="styled-by-prettify">new</span><span
style="color: #000;" class="styled-by-prettify"></span></code><br>
Replace =&gt; with -&gt; and you'll hopefully have a MyUsers
object.<br>
<br>
On 08/03/2014 03:15 AM, Ray Sleeper wrote:<br>
</div>
<blockquote
cite="mid:e19ed8c5-56fd-462d-be38-***@googlegroups.com"
type="cite">Here is the full code:<br>
<br>
<div class="prettyprint" style="background-color: rgb(250, 250,
250); border-color: rgb(187, 187, 187); border-style: solid;
border-width: 1px; word-wrap: break-word;"><code
class="prettyprint">
<div class="subprettyprint"><span style="color: #800;"
class="styled-by-prettify">#!/usr/bin/env perl</span><span
style="color: #000;" class="styled-by-prettify"><br>
<br>
</span><span style="color: #008;" class="styled-by-prettify">use</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #606;" class="styled-by-prettify">Mojolicious</span><span
style="color: #660;" class="styled-by-prettify">::</span><span
style="color: #606;" class="styled-by-prettify">Lite</span><span
style="color: #660;" class="styled-by-prettify">;</span><span
style="color: #000;" class="styled-by-prettify"><br>
</span><span style="color: #008;" class="styled-by-prettify">use</span><span
style="color: #000;" class="styled-by-prettify"> lib </span><span
style="color: #080;" class="styled-by-prettify">'lib'</span><span
style="color: #660;" class="styled-by-prettify">;</span><span
style="color: #000;" class="styled-by-prettify"><br>
</span><span style="color: #008;" class="styled-by-prettify">use</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #606;" class="styled-by-prettify">MyUsers</span><span
style="color: #660;" class="styled-by-prettify">;</span><span
style="color: #000;" class="styled-by-prettify"><br>
<br>
app</span><span style="color: #660;"
class="styled-by-prettify">-&gt;</span><span style="color:
#000;" class="styled-by-prettify">secrets</span><span
style="color: #660;" class="styled-by-prettify">([</span><span
style="color: #080;" class="styled-by-prettify">'Mojolicious
rocks'</span><span style="color: #660;"
class="styled-by-prettify">]);</span><span style="color:
#000;" class="styled-by-prettify"><br>
<br>
</span><span style="color: #800;" class="styled-by-prettify">#
Helper to lazy initialize and store our model object</span><span
style="color: #000;" class="styled-by-prettify"><br>
<br>
helper users </span><span style="color: #660;"
class="styled-by-prettify">=&gt;</span><span style="color:
#000;" class="styled-by-prettify"> </span><span
style="color: #008;" class="styled-by-prettify">sub</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">{</span><span
style="color: #000;" class="styled-by-prettify"> state
$users </span><span style="color: #660;"
class="styled-by-prettify">=</span><span style="color:
#000;" class="styled-by-prettify"> </span><span
style="color: #606;" class="styled-by-prettify">MyUsers</span><span
style="color: #660;" class="styled-by-prettify">=&gt;</span><span
style="color: #008;" class="styled-by-prettify">new</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">};</span><span
style="color: #000;" class="styled-by-prettify"><br>
<br>
any </span><span style="color: #080;"
class="styled-by-prettify">'/'</span><span style="color:
#000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">=&gt;</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #008;" class="styled-by-prettify">sub</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">{</span><span
style="color: #000;" class="styled-by-prettify"><br>
    </span><span style="color: #008;"
class="styled-by-prettify">my</span><span style="color:
#000;" class="styled-by-prettify"> $c </span><span
style="color: #660;" class="styled-by-prettify">=</span><span
style="color: #000;" class="styled-by-prettify"> shift</span><span
style="color: #660;" class="styled-by-prettify">;</span><span
style="color: #000;" class="styled-by-prettify"><br>
</span><span style="color: #800;" class="styled-by-prettify">#
Querry parameters</span><span style="color: #000;"
class="styled-by-prettify"><br>
    </span><span style="color: #008;"
class="styled-by-prettify">my</span><span style="color:
#000;" class="styled-by-prettify"> $user </span><span
style="color: #660;" class="styled-by-prettify">=</span><span
style="color: #000;" class="styled-by-prettify"> $c</span><span
style="color: #660;" class="styled-by-prettify">-&gt;</span><span
style="color: #000;" class="styled-by-prettify">param</span><span
style="color: #660;" class="styled-by-prettify">(</span><span
style="color: #080;" class="styled-by-prettify">'user'</span><span
style="color: #660;" class="styled-by-prettify">)</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">||</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #080;" class="styled-by-prettify">''</span><span
style="color: #660;" class="styled-by-prettify">;</span><span
style="color: #000;" class="styled-by-prettify"><br>
    </span><span style="color: #008;"
class="styled-by-prettify">my</span><span style="color:
#000;" class="styled-by-prettify"> $pass </span><span
style="color: #660;" class="styled-by-prettify">=</span><span
style="color: #000;" class="styled-by-prettify"> $c</span><span
style="color: #660;" class="styled-by-prettify">-&gt;</span><span
style="color: #000;" class="styled-by-prettify">param</span><span
style="color: #660;" class="styled-by-prettify">(</span><span
style="color: #080;" class="styled-by-prettify">'pass'</span><span
style="color: #660;" class="styled-by-prettify">)</span><span
style="color: #000;" class="styled-by-prettify">  </span><span
style="color: #660;" class="styled-by-prettify">||</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #080;" class="styled-by-prettify">''</span><span
style="color: #660;" class="styled-by-prettify">;</span><span
style="color: #000;" class="styled-by-prettify"><br>
<br>
</span><span style="color: #800;" class="styled-by-prettify">#
check password</span><span style="color: #000;"
class="styled-by-prettify"><br>
    </span><span style="color: #008;"
class="styled-by-prettify">return</span><span
style="color: #000;" class="styled-by-prettify"> $c</span><span
style="color: #660;" class="styled-by-prettify">-&gt;</span><span
style="color: #000;" class="styled-by-prettify">render </span><span
style="color: #008;" class="styled-by-prettify">unless</span><span
style="color: #000;" class="styled-by-prettify"> $c</span><span
style="color: #660;" class="styled-by-prettify">-&gt;</span><span
style="color: #000;" class="styled-by-prettify">users</span><span
style="color: #660;" class="styled-by-prettify">-&gt;</span><span
style="color: #000;" class="styled-by-prettify">check</span><span
style="color: #660;" class="styled-by-prettify">(</span><span
style="color: #000;" class="styled-by-prettify">$user</span><span
style="color: #660;" class="styled-by-prettify">,</span><span
style="color: #000;" class="styled-by-prettify"> $pass</span><span
style="color: #660;" class="styled-by-prettify">);</span><span
style="color: #000;" class="styled-by-prettify"><br>
    <br>
</span><span style="color: #800;" class="styled-by-prettify">#
Store username in session</span><span style="color: #000;"
class="styled-by-prettify"><br>
    $c</span><span style="color: #660;"
class="styled-by-prettify">-&gt;</span><span style="color:
#000;" class="styled-by-prettify">session</span><span
style="color: #660;" class="styled-by-prettify">(</span><span
style="color: #000;" class="styled-by-prettify">user </span><span
style="color: #660;" class="styled-by-prettify">=&gt;</span><span
style="color: #000;" class="styled-by-prettify"> $user</span><span
style="color: #660;" class="styled-by-prettify">);</span><span
style="color: #000;" class="styled-by-prettify"><br>
    $c</span><span style="color: #660;"
class="styled-by-prettify">-&gt;</span><span style="color:
#000;" class="styled-by-prettify">flash</span><span
style="color: #660;" class="styled-by-prettify">(</span><span
style="color: #000;" class="styled-by-prettify">message </span><span
style="color: #660;" class="styled-by-prettify">=&gt;</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #080;" class="styled-by-prettify">'Thanks
for logging in.'</span><span style="color: #660;"
class="styled-by-prettify">);</span><span style="color:
#000;" class="styled-by-prettify"><br>
</span><span style="color: #800;" class="styled-by-prettify">#
   redirect to protected page with 302 respons</span><span
style="color: #000;" class="styled-by-prettify"><br>
    $c</span><span style="color: #660;"
class="styled-by-prettify">-&gt;</span><span style="color:
#000;" class="styled-by-prettify">redirect_to</span><span
style="color: #660;" class="styled-by-prettify">(</span><span
style="color: #080;" class="styled-by-prettify">'protected'</span><span
style="color: #660;" class="styled-by-prettify">);</span><span
style="color: #000;" class="styled-by-prettify"><br>
</span><span style="color: #660;" class="styled-by-prettify">}</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">=&gt;</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #080;" class="styled-by-prettify">'index'</span><span
style="color: #660;" class="styled-by-prettify">;</span><span
style="color: #000;" class="styled-by-prettify"><br>
<br>
</span><span style="color: #008;" class="styled-by-prettify">group</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">{</span><span
style="color: #000;" class="styled-by-prettify"><br>
    under </span><span style="color: #008;"
class="styled-by-prettify">sub</span><span style="color:
#000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">{</span><span
style="color: #000;" class="styled-by-prettify"><br>
        </span><span style="color: #008;"
class="styled-by-prettify">my</span><span style="color:
#000;" class="styled-by-prettify"> $c </span><span
style="color: #660;" class="styled-by-prettify">=</span><span
style="color: #000;" class="styled-by-prettify"> shift</span><span
style="color: #660;" class="styled-by-prettify">;</span><span
style="color: #000;" class="styled-by-prettify"><br>
        </span><span style="color: #800;"
class="styled-by-prettify"># redirect to main with 302
response if not logged in</span><span style="color: #000;"
class="styled-by-prettify"><br>
        </span><span style="color: #008;"
class="styled-by-prettify">return</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #066;" class="styled-by-prettify">1</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #008;" class="styled-by-prettify">if</span><span
style="color: #000;" class="styled-by-prettify"> $c</span><span
style="color: #660;" class="styled-by-prettify">-&gt;</span><span
style="color: #000;" class="styled-by-prettify">session</span><span
style="color: #660;" class="styled-by-prettify">(</span><span
style="color: #080;" class="styled-by-prettify">'user'</span><span
style="color: #660;" class="styled-by-prettify">);</span><span
style="color: #000;" class="styled-by-prettify"><br>
        $c</span><span style="color: #660;"
class="styled-by-prettify">-&gt;</span><span style="color:
#000;" class="styled-by-prettify">redirect_to</span><span
style="color: #660;" class="styled-by-prettify">(</span><span
style="color: #080;" class="styled-by-prettify">'index'</span><span
style="color: #660;" class="styled-by-prettify">);</span><span
style="color: #000;" class="styled-by-prettify"><br>
        </span><span style="color: #008;"
class="styled-by-prettify">return</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #008;" class="styled-by-prettify">undef</span><span
style="color: #660;" class="styled-by-prettify">;</span><span
style="color: #000;" class="styled-by-prettify"><br>
    </span><span style="color: #660;"
class="styled-by-prettify">};</span><span style="color:
#000;" class="styled-by-prettify"><br>
    <br>
    </span><span style="color: #800;"
class="styled-by-prettify">#protected page</span><span
style="color: #000;" class="styled-by-prettify"><br>
    </span><span style="color: #008;"
class="styled-by-prettify">get</span><span style="color:
#000;" class="styled-by-prettify"> </span><span
style="color: #080;" class="styled-by-prettify">'/protected'</span><span
style="color: #660;" class="styled-by-prettify">;</span><span
style="color: #000;" class="styled-by-prettify"><br>
</span><span style="color: #660;" class="styled-by-prettify">};</span><span
style="color: #000;" class="styled-by-prettify"><br>
<br>
</span><span style="color: #800;" class="styled-by-prettify">#Logout</span><span
style="color: #000;" class="styled-by-prettify"><br>
</span><span style="color: #008;" class="styled-by-prettify">get</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #080;" class="styled-by-prettify">'/logout'</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">=&gt;</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #008;" class="styled-by-prettify">sub</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">{</span><span
style="color: #000;" class="styled-by-prettify"><br>
    </span><span style="color: #008;"
class="styled-by-prettify">my</span><span style="color:
#000;" class="styled-by-prettify"> $c </span><span
style="color: #660;" class="styled-by-prettify">=</span><span
style="color: #000;" class="styled-by-prettify"> shift</span><span
style="color: #660;" class="styled-by-prettify">;</span><span
style="color: #000;" class="styled-by-prettify"><br>
    $c</span><span style="color: #660;"
class="styled-by-prettify">-&gt;</span><span style="color:
#000;" class="styled-by-prettify">session</span><span
style="color: #660;" class="styled-by-prettify">(</span><span
style="color: #000;" class="styled-by-prettify">expires </span><span
style="color: #660;" class="styled-by-prettify">=&gt;</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #066;" class="styled-by-prettify">1</span><span
style="color: #660;" class="styled-by-prettify">);</span><span
style="color: #000;" class="styled-by-prettify"><br>
    <br>
    </span><span style="color: #800;"
class="styled-by-prettify">#redirect to main with 302</span><span
style="color: #000;" class="styled-by-prettify"><br>
    $c</span><span style="color: #660;"
class="styled-by-prettify">-&gt;</span><span style="color:
#000;" class="styled-by-prettify">redirect_to</span><span
style="color: #660;" class="styled-by-prettify">(</span><span
style="color: #080;" class="styled-by-prettify">'index'</span><span
style="color: #660;" class="styled-by-prettify">);</span><span
style="color: #000;" class="styled-by-prettify"><br>
</span><span style="color: #660;" class="styled-by-prettify">};</span><span
style="color: #000;" class="styled-by-prettify"><br>
<br>
app</span><span style="color: #660;"
class="styled-by-prettify">-&gt;</span><span style="color:
#000;" class="styled-by-prettify">start</span><span
style="color: #660;" class="styled-by-prettify">;</span><span
style="color: #000;" class="styled-by-prettify"><br>
<br>
__DATA__<br>
<br>
</span><span style="color: #660;" class="styled-by-prettify">@@</span><span
style="color: #000;" class="styled-by-prettify"> index</span><span
style="color: #660;" class="styled-by-prettify">.</span><span
style="color: #000;" class="styled-by-prettify">html</span><span
style="color: #660;" class="styled-by-prettify">.</span><span
style="color: #000;" class="styled-by-prettify">ep<br>
</span><span style="color: #660;" class="styled-by-prettify">%</span><span
style="color: #000;" class="styled-by-prettify"> layout </span><span
style="color: #080;" class="styled-by-prettify">'default'</span><span
style="color: #660;" class="styled-by-prettify">;</span><span
style="color: #000;" class="styled-by-prettify"><br>
</span><span style="color: #660;" class="styled-by-prettify">%=</span><span
style="color: #000;" class="styled-by-prettify"> form_for
index </span><span style="color: #660;"
class="styled-by-prettify">=&gt;</span><span style="color:
#000;" class="styled-by-prettify"> </span><span
style="color: #008;" class="styled-by-prettify">begin</span><span
style="color: #000;" class="styled-by-prettify"><br>
    </span><span style="color: #660;"
class="styled-by-prettify">%</span><span style="color:
#000;" class="styled-by-prettify"> </span><span
style="color: #008;" class="styled-by-prettify">if</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">(</span><span
style="color: #000;" class="styled-by-prettify">param </span><span
style="color: #080;" class="styled-by-prettify">'user'</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">)</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">{</span><span
style="color: #000;" class="styled-by-prettify"><br>
        </span><span style="color: #080;"
class="styled-by-prettify">&lt;b&gt;</span><span
style="color: #606;" class="styled-by-prettify">Wrong</span><span
style="color: #000;" class="styled-by-prettify"> name </span><span
style="color: #008;" class="styled-by-prettify">or</span><span
style="color: #000;" class="styled-by-prettify"> password</span><span
style="color: #660;" class="styled-by-prettify">,</span><span
style="color: #000;" class="styled-by-prettify"> plea </span><span
style="color: #008;" class="styled-by-prettify">try</span><span
style="color: #000;" class="styled-by-prettify"> againm</span><span
style="color: #660;" class="styled-by-prettify">.&lt;/</span><span
style="color: #000;" class="styled-by-prettify">b</span><span
style="color: #660;" class="styled-by-prettify">&gt;&lt;</span><span
style="color: #000;" class="styled-by-prettify">b</span><span
style="color: #660;" class="styled-by-prettify">&gt;</span><span
style="color: #000;" class="styled-by-prettify"><br>
    </span><span style="color: #660;"
class="styled-by-prettify">%</span><span style="color:
#000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">}</span><span
style="color: #000;" class="styled-by-prettify"><br>
    <br>
    </span><span style="color: #606;"
class="styled-by-prettify">Name</span><span style="color:
#660;" class="styled-by-prettify">:&lt;</span><span
style="color: #000;" class="styled-by-prettify">br</span><span
style="color: #660;" class="styled-by-prettify">&gt;</span><span
style="color: #000;" class="styled-by-prettify"><br>
    <br>
    </span><span style="color: #660;"
class="styled-by-prettify">%=</span><span style="color:
#000;" class="styled-by-prettify"> text_field </span><span
style="color: #080;" class="styled-by-prettify">'user'</span><span
style="color: #000;" class="styled-by-prettify"><br>
    </span><span style="color: #080;"
class="styled-by-prettify">&lt;br&gt;</span><span
style="color: #606;" class="styled-by-prettify">Password</span><span
style="color: #660;" class="styled-by-prettify">:&lt;</span><span
style="color: #000;" class="styled-by-prettify">br</span><span
style="color: #660;" class="styled-by-prettify">&gt;</span><span
style="color: #000;" class="styled-by-prettify"><br>
    <br>
    </span><span style="color: #660;"
class="styled-by-prettify">%=</span><span style="color:
#000;" class="styled-by-prettify"> submit_button </span><span
style="color: #080;" class="styled-by-prettify">'Login'</span><span
style="color: #000;" class="styled-by-prettify"><br>
</span><span style="color: #660;" class="styled-by-prettify">%</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #008;" class="styled-by-prettify">end</span><span
style="color: #000;" class="styled-by-prettify"><br>
<br>
</span><span style="color: #660;" class="styled-by-prettify">@@</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #008;" class="styled-by-prettify">protected</span><span
style="color: #660;" class="styled-by-prettify">.</span><span
style="color: #000;" class="styled-by-prettify">html</span><span
style="color: #660;" class="styled-by-prettify">.</span><span
style="color: #000;" class="styled-by-prettify">ep<br>
</span><span style="color: #660;" class="styled-by-prettify">%</span><span
style="color: #000;" class="styled-by-prettify"> layout </span><span
style="color: #080;" class="styled-by-prettify">'default'</span><span
style="color: #660;" class="styled-by-prettify">;</span><span
style="color: #000;" class="styled-by-prettify"><br>
</span><span style="color: #660;" class="styled-by-prettify">%</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #008;" class="styled-by-prettify">if</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">(</span><span
style="color: #008;" class="styled-by-prettify">my</span><span
style="color: #000;" class="styled-by-prettify"> $msg </span><span
style="color: #660;" class="styled-by-prettify">=</span><span
style="color: #000;" class="styled-by-prettify"> flash </span><span
style="color: #080;" class="styled-by-prettify">'message'</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">)</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">{</span><span
style="color: #000;" class="styled-by-prettify"><br>
  </span><span style="color: #080;"
class="styled-by-prettify">&lt;b&gt;</span><span
style="color: #660;" class="styled-by-prettify">&lt;%=</span><span
style="color: #000;" class="styled-by-prettify"> $msg </span><span
style="color: #660;" class="styled-by-prettify">%&gt;&lt;/</span><span
style="color: #000;" class="styled-by-prettify">b</span><span
style="color: #660;" class="styled-by-prettify">&gt;&lt;</span><span
style="color: #000;" class="styled-by-prettify">br</span><span
style="color: #660;" class="styled-by-prettify">&gt;</span><span
style="color: #000;" class="styled-by-prettify"><br>
  </span><span style="color: #660;"
class="styled-by-prettify">%</span><span style="color:
#000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">}</span><span
style="color: #000;" class="styled-by-prettify"><br>
  <br>
  </span><span style="color: #606;"
class="styled-by-prettify">Welcome</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">&lt;%=</span><span
style="color: #000;" class="styled-by-prettify"> session </span><span
style="color: #080;" class="styled-by-prettify">'user'</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">%&gt;.&lt;</span><span
style="color: #000;" class="styled-by-prettify">br</span><span
style="color: #660;" class="styled-by-prettify">&gt;</span><span
style="color: #000;" class="styled-by-prettify"><br>
  <br>
  </span><span style="color: #660;"
class="styled-by-prettify">%=</span><span style="color:
#000;" class="styled-by-prettify"> link_to </span><span
style="color: #606;" class="styled-by-prettify">Logout</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #660;" class="styled-by-prettify">=&gt;</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #080;" class="styled-by-prettify">'logout'</span><span
style="color: #000;" class="styled-by-prettify"><br>
  <br>
  </span><span style="color: #660;"
class="styled-by-prettify">@@</span><span style="color:
#000;" class="styled-by-prettify"> layouts</span><span
style="color: #660;" class="styled-by-prettify">/</span><span
style="color: #008;" class="styled-by-prettify">default</span><span
style="color: #660;" class="styled-by-prettify">.</span><span
style="color: #000;" class="styled-by-prettify">html</span><span
style="color: #660;" class="styled-by-prettify">.</span><span
style="color: #000;" class="styled-by-prettify">ep<br>
  <br>
  </span><span style="color: #660;"
class="styled-by-prettify">&lt;!</span><span style="color:
#000;" class="styled-by-prettify">DOCTYPE html</span><span
style="color: #660;" class="styled-by-prettify">&gt;</span><span
style="color: #000;" class="styled-by-prettify"><br>
  <br>
  </span><span style="color: #080;"
class="styled-by-prettify">&lt;html&gt;</span><span
style="color: #000;" class="styled-by-prettify"><br>
    </span><span style="color: #080;"
class="styled-by-prettify">&lt;head&gt;&lt;title&gt;</span><span
style="color: #606;" class="styled-by-prettify">Login</span><span
style="color: #000;" class="styled-by-prettify"> </span><span
style="color: #606;" class="styled-by-prettify">Manager</span><span
style="color: #660;" class="styled-by-prettify">&lt;</span><span
style="color: #080;" class="styled-by-prettify">/title&gt;&lt;/</span><span
style="color: #000;" class="styled-by-prettify">head</span><span
style="color: #660;" class="styled-by-prettify">&gt;</span><span
style="color: #000;" class="styled-by-prettify"><br>
    <br>
    </span><span style="color: #080;"
class="styled-by-prettify">&lt;body&gt;</span><span
style="color: #660;" class="styled-by-prettify">&lt;%=</span><span
style="color: #000;" class="styled-by-prettify"> content </span><span
style="color: #660;" class="styled-by-prettify">%&gt;&lt;/</span><span
style="color: #000;" class="styled-by-prettify">body</span><span
style="color: #660;" class="styled-by-prettify">&gt;</span><span
style="color: #000;" class="styled-by-prettify"><br>
 </span><span style="color: #660;"
class="styled-by-prettify">&lt;/</span><span style="color:
#000;" class="styled-by-prettify">html</span><span
style="color: #660;" class="styled-by-prettify">&gt;</span><span
style="color: #000;" class="styled-by-prettify"><br>
<br>
        <br>
<br>
        <br>
        <br>
        <br>
<br>
</span></div>
</code></div>
<br>
<br>
<br>
<br>
<br>
On Saturday, August 2, 2014 5:09:22 PM UTC-7, sri wrote:
<blockquote class="gmail_quote" style="margin: 0;margin-left:
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<div dir="ltr">
<blockquote class="gmail_quote"
style="margin:0;margin-left:0.8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div dir="ltr">Thanks for the insight, that was really
helpful.<br>
</div>
</blockquote>
<div><br>
</div>
<div>Please be nice, passive-aggressive beheavior is not
welcome here.</div>
<div><br>
</div>
<div>--</div>
<div>sebastian </div>
</div>
</blockquote>
-- <br>
You received this message because you are subscribed to the Google
Groups "Mojolicious" group.<br>
To unsubscribe from this group and stop receiving emails from it,
send an email to <a moz-do-not-send="true"
href="mailto:mojolicious+***@googlegroups.com">mojolicious+***@googlegroups.com</a>.<br>
To post to this group, send email to <a moz-do-not-send="true"
href="mailto:***@googlegroups.com">***@googlegroups.com</a>.<br>
Visit this group at <a moz-do-not-send="true"
href="http://groups.google.com/group/mojolicious">http://groups.google.com/group/mojolicious</a>.<br>
For more options, visit <a moz-do-not-send="true"
href="https://groups.google.com/d/optout">https://groups.google.com/d/optout</a>.<br>
</blockquote>
<br>
<br />--
<br />This message has been scanned for viruses and
<br />dangerous content by
<a href="http://www.mailscanner.info/"><b>MailScanner</b></a>, and is
<br />believed to be clean.
</body>
</html>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &quot;Mojolicious&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:mojolicious+***@googlegroups.com">mojolicious+***@googlegroups.com</a>.<br />
To post to this group, send email to <a href="mailto:***@googlegroups.com">***@googlegroups.com</a>.<br />
Visit this group at <a href="http://groups.google.com/group/mojolicious">http://groups.google.com/group/mojolicious</a>.<br />
For more options, visit <a href="https://groups.google.com/d/optout">https://groups.google.com/d/optout</a>.<br />
acidblue
2014-08-03 17:35:02 UTC
Permalink
AHA!
Thanks Dotan, that clears the "check" error, but i'm still getting the
"secrete not found in Mojo::etc " error.
Shoudn't that be MyUsers->new ? You've got MyUsers=>new
Replace => with -> and you'll hopefully have a MyUsers object.
#!/usr/bin/env perl
use Mojolicious::Lite;
use lib 'lib';
use MyUsers;
app->secrets(['Mojolicious rocks']);
# Helper to lazy initialize and store our model object
helper users => sub { state $users = MyUsers=>new };
any '/' => sub {
my $c = shift;
# Querry parameters
my $user = $c->param('user') || '';
my $pass = $c->param('pass') || '';
# check password
return $c->render unless $c->users->check($user, $pass);
# Store username in session
$c->session(user => $user);
$c->flash(message => 'Thanks for logging in.');
# redirect to protected page with 302 respons
$c->redirect_to('protected');
} => 'index';
group {
under sub {
my $c = shift;
# redirect to main with 302 response if not logged in
return 1 if $c->session('user');
$c->redirect_to('index');
return undef;
};
#protected page
get '/protected';
};
#Logout
get '/logout' => sub {
my $c = shift;
$c->session(expires => 1);
#redirect to main with 302
$c->redirect_to('index');
};
app->start;
__DATA__
@@ index.html.ep
% layout 'default';
%= form_for index => begin
% if (param 'user' ) {
<b>Wrong name or password, plea try againm.</b><b>
% }
Name:<br>
%= text_field 'user'
<br>Password:<br>
%= submit_button 'Login'
% end
@@ protected.html.ep
% layout 'default';
% if (my $msg = flash 'message' ) {
<b><%= $msg %></b><br>
% }
Welcome <%= session 'user' %>.<br>
%= link_to Logout => 'logout'
@@ layouts/default.html.ep
<!DOCTYPE html>
<html>
<head><title>Login Manager</title></head>
<body><%= content %></body>
</html>
Post by Ray Sleeper
Thanks for the insight, that was really helpful.
Please be nice, passive-aggressive beheavior is not welcome here.
--
sebastian
--
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
<javascript:>.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
--
This message has been scanned for viruses and
dangerous content by *MailScanner* <http://www.mailscanner.info/>, and is
believed to be clean.
--
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Per Carlson
2014-08-03 18:13:43 UTC
Permalink
Post by acidblue
AHA!
Thanks Dotan, that clears the "check" error, but i'm still getting the
"secrete not found in Mojo::etc " error.
​Are you sure you are using Mojolicious version 4.63 or newer (see:
https://github.com/kraih/mojo/blob/master/Changes#L398)?​

​What does "mojo version" tell you?​
--
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
rocko
2014-08-03 18:22:18 UTC
Permalink
mojo version returns:

Perl (v5.14.2, linux)
Mojolicious (4.19, Top Hat)

That could be the problem, I"ll upgrade and report back, but give me a
sec I gotta go grab some lunch ;)
Post by acidblue
AHA!
Thanks Dotan, that clears the "check" error, but i'm still getting
the "secrete not found in Mojo::etc " error.
https://github.com/kraih/mojo/blob/master/Changes#L398)?
<https://github.com/kraih/mojo/blob/master/Changes#L398%29?>​
​What does "mojo version" tell you?​
--
You received this message because you are subscribed to a topic in the
Google Groups "Mojolicious" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/mojolicious/WXVFOTEnghc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
--
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
rocko
2014-08-03 18:57:06 UTC
Permalink
Yep, that was it.
Upgraded to 5.25.
Had no idea I was running an older Mojo

Thanks for the help
Post by acidblue
AHA!
Thanks Dotan, that clears the "check" error, but i'm still getting
the "secrete not found in Mojo::etc " error.
https://github.com/kraih/mojo/blob/master/Changes#L398)?
<https://github.com/kraih/mojo/blob/master/Changes#L398%29?>​
​What does "mojo version" tell you?​
--
You received this message because you are subscribed to a topic in the
Google Groups "Mojolicious" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/mojolicious/WXVFOTEnghc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
--
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 mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
Loading...