src/models/User.php
public function encodePassword()
    {
        if (!$this->validate(['password'])) {
            return false;
        }
        
        // create random string for password salting
        $this->password_salt = Yii::$app->getSecurity()->generateRandomString();
        // store the password
        $this->password = Yii::$app->getSecurity()->generatePasswordHash($this->password.$this->password_salt);

        return true;
    }
public function encodePassword()
    {
        if (!$this->validate(['password'])) {
            return false;
        }
        
        // create random string for password salting
        $this->password_salt = Yii::$app->getSecurity()->generateRandomString();
        // store the password
        $this->password = Yii::$app->getSecurity()->generatePasswordHash($this->password.$this->password_salt);

        return true;
    }
public function encodePassword ( ) { if ( ! $ this -> validate ( [ 'password' ] ) ) { return false ; } // create random string for password salting $ this -> password_salt = Yii :: $ app -> getSecurity ( ) -> generateRandomString ( ) ; // store the password $ this -> password = Yii :: $ app -> getSecurity ( ) -> generatePasswordHash ( $ this -> password . $ this -> password_salt ) ; return true ; }
Encodes the current active record password field.
@return boolean
Encodes the current active record password field .