public function attemptConfirmation($code) {
    $token = Token::find()->where([
      'userId' => $this->id,
      'code' => $code,
      'type' => Token::TYPE_CONFIRMATION,
    ])->one();

    if ($token instanceof Token && !$token->isExpired) {
      $token->delete();
      if (($success = $this->confirm())) {
        Yii::$app->user->login($this, $this->module->rememberFor);
        $message = Yii::t('users', 'Thank you, registration is now complete.');
      } else {
        $message = Yii::t('users', 'Something went wrong and your account has not been confirmed.');
      }
    } else {
      $success = false;
      $message = Yii::t('users', 'The confirmation link is invalid or expired. Please try requesting a new one.');
    }

    Yii::$app->session->setFlash($success ? 'success' : 'danger', $message);

    return $success;
  }
public function attemptConfirmation($code) {
    $token = Token::find()->where([
      'userId' => $this->id,
      'code' => $code,
      'type' => Token::TYPE_CONFIRMATION,
    ])->one();

    if ($token instanceof Token && !$token->isExpired) {
      $token->delete();
      if (($success = $this->confirm())) {
        Yii::$app->user->login($this, $this->module->rememberFor);
        $message = Yii::t('users', 'Thank you, registration is now complete.');
      } else {
        $message = Yii::t('users', 'Something went wrong and your account has not been confirmed.');
      }
    } else {
      $success = false;
      $message = Yii::t('users', 'The confirmation link is invalid or expired. Please try requesting a new one.');
    }

    Yii::$app->session->setFlash($success ? 'success' : 'danger', $message);

    return $success;
  }
public function attemptConfirmation ( $ code ) { $ token = Token :: find ( ) -> where ( [ 'userId' => $ this -> id , 'code' => $ code , 'type' => Token :: TYPE_CONFIRMATION , ] ) -> one ( ) ; if ( $ token instanceof Token && ! $ token -> isExpired ) { $ token -> delete ( ) ; if ( ( $ success = $ this -> confirm ( ) ) ) { Yii :: $ app -> user -> login ( $ this , $ this -> module -> rememberFor ) ; $ message = Yii :: t ( 'users' , 'Thank you, registration is now complete.' ) ; } else { $ message = Yii :: t ( 'users' , 'Something went wrong and your account has not been confirmed.' ) ; } } else { $ success = false ; $ message = Yii :: t ( 'users' , 'The confirmation link is invalid or expired. Please try requesting a new one.' ) ; } Yii :: $ app -> session -> setFlash ( $ success ? 'success' : 'danger' , $ message ) ; return $ success ; }
Attempts user confirmation.

@param string $code Confirmation code.

@return boolean
Attempts user confirmation .