$c->user should not be used in some cases, I think it is a good idea to
specify this in the Catalyst docs, and present some alternative

"Catalyst docs"  also include C::P::Session, etc. etc.!

--vb

On 12/29/06, Octavian Rasnita <[EMAIL PROTECTED]> wrote:

 Thank you very much. I've tested and it works fine this way.
But why is not working $c->user? It is not recommended to use it, or it
may conflict with another part of my program?

If $c->user should not be used in some cases, I think it is a good idea to
specify this in the Catalyst docs, and present some alternatives.

Thank you for help.

Octavian

----- Original Message -----
*From:* vb <[EMAIL PROTECTED]>
*To:* The elegant MVC web framework <[email protected]>
*Sent:* Thursday, December 28, 2006 11:09 PM
*Subject:* Re: [Catalyst] accessing the name of the logged user

I hope this help you:

sub login_sc  : Local {
    my ( $self, $c ) = @_;
    $c->login( $c->req->params->{username}, $c->req->params->{password} );
    my $u = $c->session->{__user};
    if ($u && $c->user_object->roles) {
       my $rol = $c->user_object->roles->next;
etc...

    if($c->user_exists) {
       my $u = $c->session->{__user};
etc...

--vb

On 12/28/06, Octavian Rasnita <[EMAIL PROTECTED]> wrote:
>
> 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
>
>
> _______________________________________________
> List: [email protected]
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/[email protected]/
> Dev site: http://dev.catalyst.perl.org/
>

 ------------------------------

_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive:
http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/


_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive:
http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/



_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to