public function isLoggedIn() : bool
{
if (!$this->airship_auth instanceof Authentication) {
$this->tightenSecurityBolt();
}
$state = State::instance();
if (!empty($_SESSION['userid'])) {
// We're logged in!
if ($this instanceof Landing && $this->config('password-reset.logout')) {
return $this->verifySessionCanary($_SESSION['userid']);
}
return true;
} elseif (isset($_COOKIE['airship_token'])) {
// We're not logged in, but we have a long-term
// authentication token, so we should do an automatic
// login and, if successful, respond affirmatively.
$token = Symmetric::decrypt($_COOKIE['airship_token'], $state->keyring['cookie.encrypt_key']);
if (!empty($token)) {
return $this->doAutoLogin($token, 'userid', 'airship_token');
}
}
return false;
}