on'=>'index'));
> } else {
> $this->Session->setFlash(__('The User could
> not be saved. Please,
> try again.', true));
> }
> }
> if (empty($this->data)) {
>
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'])) {
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
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['
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
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
>
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')))
{
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
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']
if (empty($this->data)) {
$this->data = $this->User->read(null, $id);
}
}
in my view: (not complete)
input('username');
e
10 matches
Mail list logo