code: public function resetPassword(Token $token)
      {
          if (!$this->validate() || $token->user === null) {
              return false;
          }
  
          if ($token->user->resetPassword($this->password)) {
              \Yii::$app->session->setFlash('success', \Yii::t('user', 'Your password has been changed successfully.'));
              $token->delete();
          } else {
              \Yii::$app->session->setFlash('danger', \Yii::t('user', 'An error occurred and your password has not been changed. Please try again later.'));
          }
  
          return true;
      }
docs: Resets user's password.
  
  @param  Token $token
  @return bool