[Catalyst] Where to put common functions & how to get user id

jakac jakac at iprom.si
Tue May 27 15:45:43 BST 2008


Thanx! That did the trick - I never thought of it ...

So the summary is:
$c->user->get('column_name'); # doesn't work
$c->user->obj->column_name; # works!
$c->user->column_name; # works!

Thank you all for your help!

Mitch Jackson wrote:
>> My users table contains following columns:
>> * user_id
>> * username
>> * password
>> * first name, last name etc.......
>>     =

>
> the 'id' method is provided by DBIx::Class::PK, and is not one of your co=
lumns.
> have you tried $c->user->user_id instead of $c->user->id?
>
>   =

>> my $thisuser =3D $c->model('MyDB::Users')->find({username =3D> $c->user-=
>id});
>> my $thisuser_id =3D $thisuser->user_id;
>>     =

>
>   =

>> Is there a simpler way to do it? I need current user's ID in almost every
>> controller all the time...
>>     =

>
> The user object is already loaded by the authentication plugin.  You
> don't have to fetch it from the database again.
>
> $thisuser =3D $c->user->obj;
> $thisuser_id =3D $c->user->user_id
>  OR
> $thisuser_id =3D $c->user->obj->user_id;
>
>
> Hope this helps!
>
> /Mitchell K. Jackson
>
> _______________________________________________
> 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.u=
k/
> Dev site: http://dev.catalyst.perl.org/
>
>   =

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20080527/951f5=
ece/attachment.htm


More information about the Catalyst mailing list