/** * Sign in user. * Return true if it's ok. * Send password to validate it. * * @param User $user user's identity object * @param string $password user's password to validate * @param integer $duration login duration at seconds * @param boolean $testOnly Check if user can sign in with provided password * * @return boolean */ public function signInUser(User $user, $password, $duration = null, $testOnly = false) { if ($testOnly) { return $user->canSignIn() && $this->checkUserPassword($user, $password); } if (is_null($duration)) { $duration = 24 * 60 * 60 * 30 * 24; } /* @var $auth Auth */ $auth = Yii::$app->user; if ($user->canSignIn() && $this->checkUserPassword($user, $password)) { return $auth->login($user, $duration); } return false; }