Re: Keep current password

2008-06-07 Thread Timmy Crawford
on'=>'index')); > } else { > $this->Session->setFlash(__('The User could > not be saved. Please, > try again.', true)); > } > } > if (empty($this->data)) { >

Re: Keep current password

2008-06-07 Thread Dardo Sordi Bogado
I use a password_confirm, have setup the validations in the model to check password == password_confirm and have this function in my user model: function beforeSave() { if (!isset($this->data['User']['password_confirm']) || empty($this->data['User']['password_confirm'])) {

Re: Keep current password

2008-06-06 Thread b logica
Why not just remove the password field from the form and create a dedicated action/view for changing a password? Works for me. On Fri, Jun 6, 2008 at 5:15 PM, benjam <[EMAIL PROTECTED]> wrote: > > I don't think beforeSave would work, because it gets hashed even > before the method that calls Save

Re: Keep current password

2008-06-06 Thread benjam
I don't think beforeSave would work, because it gets hashed even before the method that calls Save( ). I think I may have found a cheater (read: non-cake) way of doing it... I run the following test: if ($this->Auth->password('') == $this->data['User']['password']) { unset($this->data['

Re: Keep current password

2008-06-06 Thread Matt Huggins
As an addendum, you could also do what I did in my current project to ensure that only certain fields DO validate when saving a model. This would allow you to use the method I included in my last post (specifying the fields you wish to save) while also allowing validation to work. Take a look at

Re: Keep current password

2008-06-06 Thread Chris Hartjes
On Fri, Jun 6, 2008 at 4:42 PM, benjam <[EMAIL PROTECTED]> wrote: > > If you'll notice in my controller method, that's exactly what I do, > but because it's already hashed, it's not empty, it's a hash of an > empty string. > > I need to find a way to delete it before it gets hashed. And it gets >

Re: Keep current password

2008-06-06 Thread Matt Huggins
You could specify which fields to save, including all the fields you need to update, and excluding the password field. However, you won't be able to validate the model if you do this since password will always be invalid. if ($this->User->save($this->data, false, array('username', 'email'))) {

Re: Keep current password

2008-06-06 Thread benjam
If you'll notice in my controller method, that's exactly what I do, but because it's already hashed, it's not empty, it's a hash of an empty string. I need to find a way to delete it before it gets hashed. And it gets hashed before the data gets to the method. So I need to find a way to delete

Re: Keep current password

2008-06-06 Thread Chris Hartjes
On Fri, Jun 6, 2008 at 4:33 PM, benjam <[EMAIL PROTECTED]> wrote: > I was wondering if there was a way to prevent it from hashing the > password if there is no password entered? Well, before you save the data when you're editing, you could unset the password field. i.e. unset($this->data['User']

Keep current password

2008-06-06 Thread benjam
if (empty($this->data)) { $this->data = $this->User->read(null, $id); } } in my view: (not complete) input('username'); e