[Catalyst] accessing the name of the logged user
Octavian Rasnita
orasnita at gmail.com
Thu Dec 28 18:37:57 GMT 2006
Hi,
Can you tell me how can I access the name of the currently logged user for
printing it in a TT template?
I have tried:
if ($c->user_exists) {
$c->stash->{user} = $c->user;
}
But it gives the following error:
Coldn't render template "undef error - Can't call method "from_session" on
an undefined value at
D:/usr/site/lib/Catalyst\Plugin\Authentication.pm line 122.
I have spent a lot of time for finding that this is the problem, and I even
found some threads on the list about this issue, but the only solution I
have seen was to downgrade from C::P::Authentication 0.08 to 0.007, or to
upgrade to 0.09. I am already using the version 0.09 though.
If I use the following static text, it works:
if ($c->user_exists) {
$c->stash->{user} = "Gigi";
}
So the issue is using $c->user. How can I access the user in another way
that doesn't give errors?
I have also tried (in the code and templates):
$c->user->name
$c->user->username
[% c.user %]
But all of them use in fact $c->user, so of course they didn't work.
Thank you very much for any solution.
Octavian
More information about the Catalyst
mailing list