From 49b3f507a6ab6519c4810d72e1f428f36357fe00 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Mon, 16 Nov 2015 15:57:37 -0500 Subject: [PATCH] Fix manga list updating --- public/js/manga_edit.js | 2 +- src/Aviat/AnimeClient/MenuGenerator.php | 1 + src/Aviat/AnimeClient/Model/Manga.php | 21 +++++++++++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/public/js/manga_edit.js b/public/js/manga_edit.js index 53e7dc59..840e00b9 100755 --- a/public/js/manga_edit.js +++ b/public/js/manga_edit.js @@ -35,7 +35,7 @@ dataType: 'json', method: 'POST', mimeType: 'application/json', - url: BASE_URL + '/' + CONTROLLER + '/update' + url: BASE_URL + CONTROLLER + '/update' }).done(function(res) { console.table(res); parent_sel.find("."+type+"s_read").text(completed); diff --git a/src/Aviat/AnimeClient/MenuGenerator.php b/src/Aviat/AnimeClient/MenuGenerator.php index e5fcba92..f5fcbf72 100644 --- a/src/Aviat/AnimeClient/MenuGenerator.php +++ b/src/Aviat/AnimeClient/MenuGenerator.php @@ -52,6 +52,7 @@ class MenuGenerator extends UrlGenerator { /** * Generate the full menu structure from the config files * + * @param array $menus * @return array */ protected function parse_config(array $menus) diff --git a/src/Aviat/AnimeClient/Model/Manga.php b/src/Aviat/AnimeClient/Model/Manga.php index b1ba00b5..b9ccde6b 100644 --- a/src/Aviat/AnimeClient/Model/Manga.php +++ b/src/Aviat/AnimeClient/Model/Manga.php @@ -16,6 +16,9 @@ use Aviat\AnimeClient\Model\API; use Aviat\AnimeClient\Hummingbird\Transformer; use Aviat\AnimeClient\Hummingbird\Enum\MangaReadingStatus; +use GuzzleHttp\Cookie\Cookiejar; +use GuzzleHttp\Cookie\SetCookie; + /** * Model for handling requests dealing with the manga list */ @@ -56,9 +59,23 @@ class Manga extends API { $id = $data['id']; unset($data['id']); - // @TODO update with auth key from auth class + $token = $this->container->get('auth') + ->get_auth_token(); + $domain = $this->container->get('request') + ->server->get('HTTP_HOST'); + + // Set the token cookie, with the authentication token + // from the auth class. + $cookieJar = $this->cookieJar; + $cookie_data = new SetCookie([ + 'Name' => 'token', + 'Value' => $token, + 'Domain' => 'hummingbird.me' + ]); + $cookieJar->setCookie($cookie_data); + $result = $this->put("manga_library_entries/{$id}", [ - 'cookies' => ['token' => ''], + 'cookies' => $cookieJar, 'json' => ['manga_library_entry' => $data] ]);