Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

How to update data of already logged-in user?

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


sergey.programmer at gmail

Jul 11, 2012, 8:37 AM

Post #1 of 4 (212 views)
Permalink
How to update data of already logged-in user?

Hello,

My question is simple. I have object of already authenticated user in $u by
using

my $u = $c->user()

So, getter $u->email reflects actual email. How then can I update already
loaded user object? E.g. i need something like:

print $u->email; # old [at] emai

$u->email = 'new [at] emai';

print $u->email; # new [at] emai

How to achieve this simple way? Do I need to update user rec in DB then
re-load user from DB? Then, which is the simplest way to re-trieve user
again?

Thank you.
Sergey


davewood at gmx

Jul 11, 2012, 9:07 AM

Post #2 of 4 (206 views)
Permalink
Re: How to update data of already logged-in user? [In reply to]

The object returned by $c->user is not what you are looking for.

I assume you are using DBIC.

Get the "real" user object with $c->user->get_object()

http://search.cpan.org/~bobtfish/Catalyst-Plugin-Authentication-0.10021/lib/Catalyst/Authentication/User.pm#get_object(_)

cheers
david



On 11 July 2012 17:37, Sergey Dmitriev <sergey.programmer [at] gmail> wrote:
> Hello,
>
> My question is simple. I have object of already authenticated user in $u by
> using
>
> my $u = $c->user()
>
> So, getter $u->email reflects actual email. How then can I update already
> loaded user object? E.g. i need something like:
>
> print $u->email; # old [at] emai
>
> $u->email = 'new [at] emai';
>
> print $u->email; # new [at] emai
>
> How to achieve this simple way? Do I need to update user rec in DB then
> re-load user from DB? Then, which is the simplest way to re-trieve user
> again?
>
> Thank you.
> Sergey
>
>
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


sergey.programmer at gmail

Jul 11, 2012, 11:28 AM

Post #3 of 4 (212 views)
Permalink
Re: How to update data of already logged-in user? [In reply to]

Thank you David!

2012/7/11 David Schmidt <davewood [at] gmx>

> The object returned by $c->user is not what you are looking for.
>
> I assume you are using DBIC.
>
> Get the "real" user object with $c->user->get_object()
>
>
> http://search.cpan.org/~bobtfish/Catalyst-Plugin-Authentication-0.10021/lib/Catalyst/Authentication/User.pm#get_object(_)
>
> cheers
> david
>
>
>
> On 11 July 2012 17:37, Sergey Dmitriev <sergey.programmer [at] gmail>
> wrote:
> > Hello,
> >
> > My question is simple. I have object of already authenticated user in $u
> by
> > using
> >
> > my $u = $c->user()
> >
> > So, getter $u->email reflects actual email. How then can I update already
> > loaded user object? E.g. i need something like:
> >
> > print $u->email; # old [at] emai
> >
> > $u->email = 'new [at] emai';
> >
> > print $u->email; # new [at] emai
> >
> > How to achieve this simple way? Do I need to update user rec in DB then
> > re-load user from DB? Then, which is the simplest way to re-trieve user
> > again?
> >
> > Thank you.
> > Sergey
> >
> >
> >
> > _______________________________________________
> > List: Catalyst [at] lists
> > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> > Searchable archive:
> http://www.mail-archive.com/catalyst [at] lists/
> > Dev site: http://dev.catalyst.perl.org/
> >
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>


luguoqing at gmail

Jul 11, 2012, 7:54 PM

Post #4 of 4 (203 views)
Permalink
Re: How to update data of already logged-in user? [In reply to]

my $user = $c->find_user({ user_id => $c->user->user_id });
$c->set_authenticated($user);

$user->email will be the new email.


On Thu, Jul 12, 2012 at 2:28 AM, Sergey Dmitriev <
sergey.programmer [at] gmail> wrote:

> Thank you David!
>
> 2012/7/11 David Schmidt <davewood [at] gmx>
>
>> The object returned by $c->user is not what you are looking for.
>>
>> I assume you are using DBIC.
>>
>> Get the "real" user object with $c->user->get_object()
>>
>>
>> http://search.cpan.org/~bobtfish/Catalyst-Plugin-Authentication-0.10021/lib/Catalyst/Authentication/User.pm#get_object(_)
>>
>> cheers
>> david
>>
>>
>>
>> On 11 July 2012 17:37, Sergey Dmitriev <sergey.programmer [at] gmail>
>> wrote:
>> > Hello,
>> >
>> > My question is simple. I have object of already authenticated user in
>> $u by
>> > using
>> >
>> > my $u = $c->user()
>> >
>> > So, getter $u->email reflects actual email. How then can I update
>> already
>> > loaded user object? E.g. i need something like:
>> >
>> > print $u->email; # old [at] emai
>> >
>> > $u->email = 'new [at] emai';
>> >
>> > print $u->email; # new [at] emai
>> >
>> > How to achieve this simple way? Do I need to update user rec in DB then
>> > re-load user from DB? Then, which is the simplest way to re-trieve user
>> > again?
>> >
>> > Thank you.
>> > Sergey
>> >
>> >
>> >
>> > _______________________________________________
>> > List: Catalyst [at] lists
>> > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
>> > Searchable archive:
>> http://www.mail-archive.com/catalyst [at] lists/
>> > Dev site: http://dev.catalyst.perl.org/
>> >
>>
>> _______________________________________________
>> List: Catalyst [at] lists
>> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
>> Searchable archive:
>> http://www.mail-archive.com/catalyst [at] lists/
>> Dev site: http://dev.catalyst.perl.org/
>>
>
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>
>


--
Jack

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.