Skip to content

Commit

Permalink
Delete window.Laravel.csrfToken for #4260 (#19135)
Browse files Browse the repository at this point in the history
If PR laravel/laravel#4260 is accepted we will no longer need window.Laravel
  • Loading branch information
DrowningElysium authored and taylorotwell committed May 10, 2017
1 parent beb3b03 commit 020b783
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/Illuminate/Auth/Console/stubs/make/views/layouts/app.stub
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@

<!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet">

<!-- Scripts -->
<script>
window.Laravel = {!! json_encode([
'csrfToken' => csrf_token(),
]) !!};
</script>
</head>
<body>
<div id="app">
Expand Down

4 comments on commit 020b783

@Cannonb4ll
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DrowningElysium I have read the issue where this was removed, but I do not understand why it was removed. Could you elaborate for me?

@DrowningElysium
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cannonb4ll I removed it as in the docs it said that adding the csrf meta tag is enough https://laravel.com/docs/5.4/csrf#csrf-x-csrf-token, while this is not the case if you created your layout manually but do wish to use the out of the box js. So you have to generate first the app layout before you can find out that you need to use a object with the token inside to be able to use the out of the box script.

@Cannonb4ll
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah alright, thank you! I still have a project which utilises the JS object in the header, shouldn't be any harm I recon right?

@DrowningElysium
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah if you just use the old csrf = window.Laravel.csrf then you are fine to use an object. Everyone can choose what they want still.

Please sign in to comment.