/** * Gets the user associated with the token */ public function authorize($username) { $this->qhandle->query = "SELECT * FROM access_tokens WHERE token = ?"; $param = [$this->token]; if ($this->qhandle->exec($param) && ($result = $this->qhandle->fetch())) { $user = new User($this->pdo); $user->user_id = $result["user_id"]; $user->fetch_with_id(); if ($user->username === $username) { $this->user = $user; return $this->authorized = true; } } return $this->authorized = false; }