diff --git a/src/APnutI.php b/src/APnutI.php index c36b7c8..72ec436 100644 --- a/src/APnutI.php +++ b/src/APnutI.php @@ -328,7 +328,7 @@ class APnutI } //TODO: Ping server and validate token - public function isAuthenticated(bool $allow_server_token = false): bool + public function isAuthenticated(bool $allow_server_token = false, bool $skip_verify_token = false): bool { $is_authenticated = ($allow_server_token && !empty($this->server_token)) || isset($this->access_token); diff --git a/src/Entities/Poll.php b/src/Entities/Poll.php index d23b19d..06b89e6 100644 --- a/src/Entities/Poll.php +++ b/src/Entities/Poll.php @@ -122,6 +122,13 @@ class Poll return $type === Poll::$notice_type || in_array($type, Poll::$poll_types); } + public function canVote() + { + $is_authenticated = $this->api->isAuthenticated(false, true); + $is_closed = $this->closed_at >= new \DateTime(); + return $is_authenticated && !$is_closed; + } + public function __toString(): string { if (!empty($this->user)) {