skeeks\cms\models\User::setPassword PHP Method

setPassword() public method

Generates password hash from password and sets it to the model
public setPassword ( string $password )
$password string
    public function setPassword($password)
    {
        $this->password_hash = Yii::$app->security->generatePasswordHash($password);
    }

Usage Example

Example #1
0
 /**
  * Logs in a user using the provided username and password.
  *
  * @return boolean whether the user is logged in successfully
  */
 public function changePassword()
 {
     if ($this->validate() && $this->new_password == $this->new_password_confirm && $this->new_password) {
         $this->user->setPassword($this->new_password);
         return $this->user->save(false);
     } else {
         return false;
     }
 }