I would make non_auth a component:
<div class="small_text"> <h1><% $message %>You are not logged in:</h1> If you don't have a login, Click <a href="/create_user.html">here</a +> to create one. </div> <form method="post" action="/index.html"> <table class="form_fields"> <tr> <td>User Name: </td> <td><input type="text" name="name_user" /></td> </tr> <tr> <td>Password: </td> <td><input type="password" name="password" value="" alt="Require +d only for admins"/></td> </tr> </table> <div style="text-align:right"> <input type="submit" value="Proceed" /> </div> </form> <%args> $message => '' </%args>
Then in /auth_required/autohandler :
<%init> my $log_in_status = My::App->authenitcate_user($r); if ($log_in_status eq 'OK') { $m->call_next; # proceeed to /auth_required/foo.html } else { my $message = $m->comp('/get_message', key => $log_in_status); $m->comp('/non_auth', message => $message); } </%init>
where get_message looks like:
<% $message %> <%args> $key </%args> <%init> my $message = $key ? $Messages{$key} : '&nbsp;'; </%init> <%once> my %Messages = ( http_title => 'Welcome', # Invalid user name or password OR username deleted from table 101 => 'Invalid username or password', # No cookie sent to server 201 => 'An error has occured', # The session id from cookie was invalid 301 => 'An error has occured' ); </%once>

In reply to Re: Problem with Mason, can it be solved with a subrequest? by Arunbear
in thread Problem with Mason, can it be solved with a subrequest? by EvanCarroll

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.