Fellow monks,
I'm having a slight
problem with mason: =[
So here it is: I have an autohandler:
/auth_required/autohandler and I want it to throw different useful error messages at different parts if authentication fails. These error messages are stored in
/index.html, in separate method which makes another method call with content to reload the login form with the appropriate message prefixed:
<%method .non_auth>
<div class="small_text">
<h1><% $m->content %>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="Requi
+red only for admins"/></td>
</tr>
</table>
<div style="text-align:right">
<input type="submit" value="Proceed" />
</div>
</form>
</%method>
%# Invalid user name or password OR username deleted from table
<%method .error_auth>
<&| SELF:.non_auth &>101: Invalid username or password, </&>
</%method>
Like that of sort
Essentially what I would like to do is
create a subrequest out of a method located in a different component. So if the autohandler at
/auth_required/autohandler, fails
/index.html's
.error_auth or similar gets invoked, which causes the error to precede
'You are not logged in'; with a useful message.
One way around this problem would be to call the method from
/auth_required/autohandler. But, that should be _bad-practice_, because I would have to clear the buffer (
$m->flush_buffer) and abort (
$m->abort)which would mean I miss out on the header and footer information in
/autohandler.
Another method would be to extract each error message into its own file so I can make a subrequest (
$m->subexec) out of it or redirect (
$m->redirect) to it. This isn't a "Bad" approach per se, but I would prefer to keep all of my error messages in one file, for quicker referencing.
Any ideas?
Evan Carroll
www.EvanCarroll.com
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.