<br><br><div class="gmail_quote">On Wed, Sep 30, 2009 at 10:13 AM, Aristotle Pagaltzis <span dir="ltr">&lt;<a href="mailto:pagaltzis@gmx.de">pagaltzis@gmx.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><div class="im"><br>
<br>
</div>I detach. My login action sets status 403 and pragma no-cache<br>
(etc) when it’s not requested directly. I’d love to be able to<br>
just send 401 instead and let the user agent take care of<br>
everything (which would transparently and securely deal with<br>
POSTs sent with expired auth credentials) – unfortunately the<br>
HTTP Auth UI in browsers is universally shoddy. If I felt the<br>
need, I could also check for browser vs automated agent and send<br>
either form + 403 to browsers and just a 401 to other clients.<br></blockquote><div><br>Looking at my code I also return 401 for API requests.  I have a note in the code that there was problems returning 403 on some browsers although maybe that was just old IE when the content body was too short and it would display its own message.<br>
<br>And looking at old svn logs I found another reason I redirect -- which might be how my code grew over time.<br><br>At one point I added a &quot;remember me&quot; feature.  So I have code in the controller&#39;s auto() which is basically &quot;return unless $c-&gt;test_role( @roles );&quot; That test_role() method first checks if logged in, and if not logged in then does the redirect.  But, before doing the redirect it attempts an automatic login via the &quot;remember me&quot; feature.<br>
<br>The problem there was then the action&#39;s auto() and begin() methods were not run with the user logged in, which was important for other reasons.<br><br>I would have expected to do the &quot;remember me&quot; login earlier (e.g. in root&#39;s auto() ) and avoided that issue, but mabye I had a reason otherwise.  Anyway, the redirect does allow the login action to be called as a normal request (with login&#39;s auto and begin methods run).<br>
<br>Granted, now there&#39;s $c-&gt;go to do a full dispatch, but redirect seems cleaner at the expense of a redirect.<br></div><div><br><br></div></div><br clear="all"><br>-- <br>Bill Moseley<br><a href="mailto:moseley@hank.org">moseley@hank.org</a><br>