[Catalyst] Weird problem with Catalyst::Authentication, and redirects

David Schmidt davewood at gmx.at
Wed Jan 26 12:48:21 GMT 2011


On Wed, Jan 26, 2011 at 12:18 PM, Ben van Staveren
<benvanstaveren at gmail.com> wrote:
> Hi Denny & list,
>
>> Have you tried turning it off and then on again?  ;)
>>
> Repeatedly :)
>
>> More seriously, I have found on multiple occasions that the Catalyst
>> Auth stuff can seem to get itself into an inconsistent state, such that
>> it starts behaving oddly (usually mine will successfully log in, but
>> fail to keep track of that fact), and the only way to fix it is to
>> delete the contents of the session store (database, in my case), delete
>> all the cookies for the site, and possibly wipe the browser cache too.
>>
>> Other than that I'm not sure what to suggest.  Where does the auto
>> return to?  Is it possible it's coming back from there to before the
>> dashboard redirect, and so the redirect URL is getting overwritten
>> before the output is constructed?  (I've not used auto, so no idea if
>> this is a stupid question or not.)
>>
> On the off-hand of being wrong, as far as I know, auto is called before
> anything else is really done, so your dispatch chain ends up going
>
> auto -> action -> end
>
> I think. Anyways, I did clear the session store, zapped all the cookies, and
> the behaviour's still there. I did some Data::Dumper action, and even after
> the RenderView action class had it's way with things, the status is still
> set to 302, a Location header is present in the output, but it did render
> the template that it's not supposed to render.
>
> Even if I do a "$c->detach('end') and return 0", it will render a template,
> which by all accounts, it's not supposed to be doing.
>
> Doing a telnet to the dev server and querying it does return the proper
> headers for a redirect as well; Status: 302 and Location: /login - but it
> also renders the output body, for some really freaky reason.
>
> The main issue for me is that this behaviour seems to be triggered by
> something I did in controller code somewhere, but I could swear up and down
> that I haven't done anything that touches even remotely near authentication
> or the Auth guts, so I'm totally and utterly stumped. And it's kind of
> important this works, deadlines and such things :(
>
> --
>
> Ben van Staveren
> phone: +62 81 70777529
> email: benvanstaveren at gmail.com
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>



If all you want to do is redirecting the user to /login if he isn't
logged in you could try CatalystX::SimpleLogin.
Using auto for that stuff is kinda deprecated according to what I
overheard in the irc channel.

I couldn't find an error in what little information you have provided.
I'd probably go and

-) check if all relevant modules are up to date.
-) try with a different browser
-) create a simple app and try this particular code there.

david



More information about the Catalyst mailing list