From cafb7ad654f4cdcc849668b5134076ffcfb7dcb6 Mon Sep 17 00:00:00 2001 From: aymm Date: Sat, 27 Mar 2021 13:56:53 +0000 Subject: [PATCH] Caching current user --- src/APnutI.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/APnutI.php b/src/APnutI.php index 9575b82..aec2c78 100644 --- a/src/APnutI.php +++ b/src/APnutI.php @@ -42,6 +42,8 @@ class APnutI protected string $token_redirect_after_auth; protected ?string $server_token_file_path = null; + protected ?User $current_user = null; + public ?Meta $meta = null; /* @@ -383,6 +385,7 @@ class APnutI { unset($_SESSION[$this->token_session_key]); $this->access_token = null; + $this->current_user = null; } // TODO @@ -539,7 +542,8 @@ class APnutI public function getAuthorizedUser(): User { - return new User($this->get('/users/me'), $this); + $this->current_user ??= new User($this->get('/users/me'), $this); + return $this->current_user; } public function getUser(int $user_id, array $args = [])