[Catalyst] Authentication gotchas
Jess Robinson
castaway at desert-island.demon.co.uk
Fri Dec 16 12:56:24 CET 2005
Well, I'm sure theres a note somewhere, that says "don't put actions into
your main app file!"..
But I agree, it should be written bigger and bolder in more places.
Basically: Don't do that then!
Jess
On Fri, 16 Dec 2005, Nigel Metheringham wrote:
> The authentication documentation examples, including the one in the
> advent calendar:-
> http://catalyst.perl.org/calendar/2005/14
>
> pretty much all have the same set of example code, eg:-
> use Catalyst qw/Authentication
> ...
>
> sub login : Local {
> my ($self, $c) = @_;
>
> if ( my $user = $c->req->param("user")
> and my $password = $c->req->param("password") )
> {
> if ( $c->login( $user, $password ) ) {
> $c->res->body( "hello " . $c->user->name );
> } else {
> # login incorrect
> }
> }
> else {
> # invalid form input
> }
> }
>
> Unfortunately as written these tend to do interesting and unintended
> things if you put them into the main app module. [Hint: what class is
> $c? What happens when the login method calls $c->login($user,
> $pass)?? ]
>
> This stuff is easy to spot when you get an idea of whats happening, but
> its bloody confusing for the poor sods trying this for the first time
> and finding the example code just goes bang with a very strange error
> message (in this case it tries to find a login method in a class named
> for the user id you are logging in with).
>
> I have to say the Advent Calendar snippets have been really useful for
> me. We need to pull all of these together to make some more
> tutorial/example docs.
>
> Nigel.
> --
> [ Nigel Metheringham Nigel.Metheringham at InTechnology.co.uk ]
> [ - Comments in this message are my own and not ITO opinion/policy - ]
>
>
>
> _______________________________________________
> Catalyst mailing list
> Catalyst at lists.rawmode.org
> http://lists.rawmode.org/mailman/listinfo/catalyst
>
>
More information about the Catalyst
mailing list