Skip to content

Commit

Permalink
remove token from request
Browse files Browse the repository at this point in the history
  • Loading branch information
EsdertCO committed Sep 1, 2020
1 parent bc8b44a commit 690d84d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 22 deletions.
2 changes: 1 addition & 1 deletion src/Config/laravel-stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* When type is uuid it will generate a random uuid for the field.
*/
'user' => [
'model' => '\App\User',
'model' => '\App\Models\User',
'unique' => 'email',
'fields' => [
'name',
Expand Down
5 changes: 0 additions & 5 deletions src/Console/Patch.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,13 @@ private function handleCookiePatching()
$middlewarePath = \config('laravel-stubs.patch.middleware_folder').'/VerifyCsrfToken.php';
$middlewareSerialized = \file_get_contents(__DIR__.'/../stubs/cookies/cookiemiddleware_serialized.stub');
$middlewareAddCookieToResponse = \file_get_contents(__DIR__.'/../stubs/cookies/cookiemiddleware_addCookieToResponse.stub');
$middlewareGetTokenFromRequest = \file_get_contents(__DIR__.'/../stubs/cookies/cookiemiddleware_getTokenFromRequest.stub');
$use = \file_get_contents(__DIR__.'/../stubs/cookies/cookiemiddleware_use.stub');

$fileContents = \file_get_contents($middlewarePath);
if (!Str::contains($fileContents, $use)) {
$fileContents = preg_replace('/(use .+;)([\s]+class)/', "$1\n".\preg_replace("/[ |\t]{2,}/", "", $use)."$2",
$fileContents);
}
if (!Str::contains($fileContents, 'protected function getTokenFromRequest')) {
$fileContents = preg_replace('/(class .*[\s\S]{[.|\s|\S]*)(})/', "$1\n".$middlewareGetTokenFromRequest."\n$2",
$fileContents);
}
if (!Str::contains($fileContents, 'protected function addCookieToResponse')) {
$fileContents = preg_replace('/(class .*[\s\S]{[.|\s|\S]*)(})/', "$1\n".$middlewareAddCookieToResponse."\n$2",
$fileContents);
Expand Down
16 changes: 0 additions & 16 deletions src/stubs/cookies/cookiemiddleware_getTokenFromRequest.stub

This file was deleted.

0 comments on commit 690d84d

Please sign in to comment.