On Thu, Sep 16, 2010 at 2:41 AM, andrewperk <[email protected]> wrote:
> Thanks for responding Andrei,
>
> I didn't think I was submitting the user's ID. I thought I was just
> comparing the users id to the logged in users to id to make sure they
> match before the update takes place. This would ensure that the logged
> in user is only updating his profile and can't change it to be someone
> else's.
>
> So is the: "&& ($this->User->id == $this->Auth->user('id')" part
> unnecessary? I think I may be doing it wrong. I'm just worried that a
> user could change the ID that the form is submitting to and update
> someone else's profile. I see in the html source code that it's still
> generating "action="users/edit/6"" even though my users edit action
> doesn't take an ID as a parameter. Thanks.
This is what I do:
public function edit()
{
$id = $this->Auth->user('id');
if (!empty($this->data))
{
$this->data['Member']['id'] = $id;
if ($this->Member->save($this->data))
{
...
}
}
else
{
$this->data = $this->Member->read(null, $id);
}
...
}
Of course, I also ensure that edit is not an allowed action.
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en