thrownewException('Unknown error occurred while generating hash.');
switch($this->passwordHashStrategy){
case'password_hash':
if(!function_exists('password_hash')){
thrownewInvalidConfigException('Password hash key strategy "password_hash" requires PHP >= 5.5.0, either upgrade your environment or use another strategy.');
@@ -351,6 +368,7 @@ class Security extends Component
* @param string $hash The hash to verify the password against.
* @return boolean whether the password is correct.
* @throws InvalidParamException on bad password or hash parameters or if crypt() with Blowfish hash is not available.
* @throws InvalidConfigException on unsupported password hash strategy is configured.
* @see generatePasswordHash()
*/
publicfunctionvalidatePassword($password,$hash)
...
...
@@ -363,13 +381,22 @@ class Security extends Component
thrownewInvalidParamException('Hash is invalid.');
}
$test=crypt($password,$hash);
$n=strlen($test);
if($n<32||$n!==strlen($hash)){
returnfalse;
switch($this->passwordHashStrategy){
case'password_hash':
if(!function_exists('password_verify')){
thrownewInvalidConfigException('Password hash key strategy "password_hash" requires PHP >= 5.5.0, either upgrade your environment or use another strategy.');