dre1080 / warden

More than just a user database auth package for FuelPHP
http://dre1080.github.com/warden
MIT License
46 stars 11 forks source link

Error with user password validation 'warden.validation.password.too_short' #31

Closed PrimozRome closed 11 years ago

PrimozRome commented 11 years ago

In user model where the validation of min and max password length is done there is an error with throwing 'warden.validation.password.too_short' exception. There is one ")" to much when passing parameters to \Orm\ValidationFailed!

Current code:

 
if (!empty($this->password)) {
    if (\Str::length($this->password) < $min_length) {
        throw new \Orm\ValidationFailed(__('warden.validation.password.too_short'), array('count' => $min_length));
    } elseif (\Str::length($this->password) > $max_length) {
        throw new \Orm\ValidationFailed(__('warden.validation.password.too_long', array('count' => $max_length)));
    }
    $this->encrypted_password = Warden::encrypt_password($this->password);
}

Fixed code:

 
if (!empty($this->password)) {
    if (\Str::length($this->password) < $min_length) {
        throw new \Orm\ValidationFailed(__('warden.validation.password.too_short', array('count' => $min_length));
    } elseif (\Str::length($this->password) > $max_length) {
        throw new \Orm\ValidationFailed(__('warden.validation.password.too_long', array('count' => $max_length)));
    }
    $this->encrypted_password = Warden::encrypt_password($this->password);
}

Notice the ")" in current code when throwing 'warden.validation.password.too_short'

The above code in current Warden trowed this Exception:

ErrorException [ Error ]: Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]]) PKGPATH/orm/classes/observer/validation.php @ line 35

BR Primoz

PrimozRome commented 11 years ago

I have initiated a pull request for this issue: https://github.com/dre1080/warden/pull/32