From 249e6e696e22d2eb4abc1ace82d70220db53e8ed Mon Sep 17 00:00:00 2001 From: shalvah Date: Thu, 9 Sep 2021 20:21:07 +0100 Subject: [PATCH] Remove `csrf_cookie_name` --- config/scribe.php | 7 +------ resources/js/tryitout.js | 2 +- resources/views/themes/default/index.blade.php | 1 - src/Commands/GenerateDocumentation.php | 2 +- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/config/scribe.php b/config/scribe.php index 9d0da79e..a8f8e506 100644 --- a/config/scribe.php +++ b/config/scribe.php @@ -187,7 +187,7 @@ 'base_url' => null, /** - * Fetch a CSRF token before each request. Needed if you're using Laravel Sanctum. + * Fetch a CSRF token before each request, and add it as an X-XSRF-TOKEN header. Needed if you're using Laravel Sanctum. */ 'use_csrf' => false, @@ -195,11 +195,6 @@ * The URL to fetch the CSRF token from (if `use_csrf` is true). */ 'csrf_url' => '/sanctum/csrf-token', - - /** - * The name of the cookie to fetch the CSRF token from after hitting the `csrf_url`. - */ - 'csrf_cookie_name' => 'XSRF-TOKEN', ], /* diff --git a/resources/js/tryitout.js b/resources/js/tryitout.js index d2db9e92..4a55df1f 100644 --- a/resources/js/tryitout.js +++ b/resources/js/tryitout.js @@ -227,7 +227,7 @@ async function executeTryOut(endpointId, form) { let preflightPromise = Promise.resolve(); if (window.useCsrf && window.csrfUrl) { preflightPromise = makeAPICall('GET', window.csrfUrl, {}, {}, {}, null).then(() => { - headers['X-XSRF-TOKEN'] = getCookie(window.csrfCookieName); + headers['X-XSRF-TOKEN'] = getCookie('XSRF-TOKEN'); }); } diff --git a/resources/views/themes/default/index.blade.php b/resources/views/themes/default/index.blade.php index 08dbde58..00f8758d 100644 --- a/resources/views/themes/default/index.blade.php +++ b/resources/views/themes/default/index.blade.php @@ -26,7 +26,6 @@ var baseUrl = "{{ $tryItOut['base_url'] ?? config('app.url') }}"; var useCsrf = Boolean({{ $tryItOut['use_csrf'] ?? null }}); var csrfUrl = "{{ $tryItOut['csrf_url'] ?? null }}"; - var csrfCookieName = "{{ $tryItOut['csrf_cookie_name'] ?? "XSRF-TOKEN" }}"; @endif diff --git a/src/Commands/GenerateDocumentation.php b/src/Commands/GenerateDocumentation.php index 4e94db0c..a8d12dbf 100644 --- a/src/Commands/GenerateDocumentation.php +++ b/src/Commands/GenerateDocumentation.php @@ -120,7 +120,7 @@ protected function upgradeConfigFileIfNeeded(): void $changes = $upgrader->dryRun(); if (!empty($changes)) { $this->newLine(); - sleep(0.4); + $this->warn("You're using an updated version of Scribe, which added new items to the config file."); $this->info("Here are the changes:"); foreach ($changes as $change) {