philipbrown / magniloquent

DEPRECATED, USE https://github.com/dwightwatson/validating
MIT License
70 stars 8 forks source link

What i'm missing in autoHash()? #38

Closed RicardoRamirezR closed 10 years ago

RicardoRamirezR commented 10 years ago

This way is used here:

private function autoHash()
  {
    if (isset($this->attributes['password']))
    {
      if ($this->attributes['password'] != $this->getOriginal('password'))
        $this->attributes['password'] = Hash::make($this->attributes['password']);
      }
}

$this->attributes['password'] is the new one in plain, right? $this->getOriginal('password') is the old one hashed, right?

wouldn't be better to use:

if ( ! Hash::check($this->attributes['password'], $this->getOriginal('password'))) 
{
  $this->attributes['password'] = Hash::make($this->attributes['password']);                
}

Nooo, I'm missing something, right?

As autoHash() is private I can't overwrite it...

philipbrown commented 10 years ago

Hmm, yeah your way looks right to me. I can't really remember why it was written like that in the first place tbh.