Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add js script to set CSRF token for all Ajax call.
  • Loading branch information
sroutier committed Jun 3, 2016
1 parent 74b40e1 commit a367d98
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 25 deletions.
1 change: 1 addition & 0 deletions gulpfile.js
Expand Up @@ -26,6 +26,7 @@ elixir(function(mix) {
// Combine the various JS into one.
mix.scripts([
//'vendor.js',
'ajax-csrf.js',
'modal.js',
'app.js',
], null, 'public/js');
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/build/js/all.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/build/rev-manifest.json
@@ -1,4 +1,4 @@
{
"css/all.css": "css/all-ba1bbac4.css",
"js/all.js": "js/all-c4fcd39f.js"
"js/all.js": "js/all-91702b9f.js"
}
6 changes: 6 additions & 0 deletions public/js/ajax-csrf.js
@@ -0,0 +1,6 @@
// Set CSRF token for all jQuery/Ajax requests.
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
})
7 changes: 7 additions & 0 deletions public/js/all.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/js/all.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 23 additions & 6 deletions resources/themes/default/layouts/master.blade.php
Expand Up @@ -26,15 +26,32 @@
<!-- Head -->
@include('partials._head')

<!-- Optional header section -->
@yield('head_extra')
<!-- REQUIRED JS SCRIPTS -->

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<!-- jQuery 2.1.4 -->
<script src="{{ asset ("/bower_components/admin-lte/plugins/jQuery/jQuery-2.1.4.min.js") }}"></script>
<!-- Bootstrap 3.3.2 JS -->
<script src="{{ asset ("/bower_components/admin-lte/bootstrap/js/bootstrap.min.js") }}" type="text/javascript"></script>
<!-- AdminLTE App -->
<script src="{{ asset ("/bower_components/admin-lte/dist/js/app.min.js") }}" type="text/javascript"></script>

<!-- Optionally, you can add Slimscroll and FastClick plugins.
Both of these plugins are recommended to enhance the
user experience. Slimscroll is required when using the
fixed layout. -->

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<![endif]-->

<!-- Application JS-->
<script src="{{ asset(elixir('js/all.js')) }}"></script>

<!-- Optional header section -->
@yield('head_extra')

</head>

Expand Down
3 changes: 0 additions & 3 deletions resources/themes/default/partials/_body.blade.php
Expand Up @@ -38,7 +38,4 @@
</div>
</div>

<!-- Application JS-->
<script src="{{ asset(elixir('js/all.js')) }}"></script>

</body>
13 changes: 0 additions & 13 deletions resources/themes/default/partials/_footer.blade.php
@@ -1,13 +0,0 @@
<!-- REQUIRED JS SCRIPTS -->

<!-- jQuery 2.1.4 -->
<script src="{{ asset ("/bower_components/admin-lte/plugins/jQuery/jQuery-2.1.4.min.js") }}"></script>
<!-- Bootstrap 3.3.2 JS -->
<script src="{{ asset ("/bower_components/admin-lte/bootstrap/js/bootstrap.min.js") }}" type="text/javascript"></script>
<!-- AdminLTE App -->
<script src="{{ asset ("/bower_components/admin-lte/dist/js/app.min.js") }}" type="text/javascript"></script>

<!-- Optionally, you can add Slimscroll and FastClick plugins.
Both of these plugins are recommended to enhance the
user experience. Slimscroll is required when using the
fixed layout. -->

0 comments on commit a367d98

Please sign in to comment.