Skip to content

Commit

Permalink
Merge pull request openfoodfoundation#6685 from Matt-Yorkley/angular-…
Browse files Browse the repository at this point in the history
…csrf

[Rails 5] Update Angular CSRF handling
  • Loading branch information
andrewpbrett authored Jan 21, 2021
2 parents 0e7f4b2 + ea9ebc8 commit 0f92b3c
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ gem 'mini_racer', '0.2.15'

gem 'uglifier', '>= 1.0.3'

gem 'angular_rails_csrf'
gem 'foundation-icons-sass-rails'

gem 'foundation-rails', '= 5.5.2.1'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ GEM
railties (>= 3.1)
sprockets (~> 2.0)
tilt
angular_rails_csrf (4.2.0)
railties (>= 3, < 7)
angularjs-file-upload-rails (2.4.1)
angularjs-rails (1.5.5)
arel (6.0.4)
Expand Down Expand Up @@ -732,6 +734,7 @@ DEPENDENCIES
acts_as_list (= 0.9.19)
andand
angular-rails-templates (~> 0.3.0)
angular_rails_csrf
angularjs-file-upload-rails (~> 2.4.1)
angularjs-rails (= 1.5.5)
atomic
Expand Down
3 changes: 3 additions & 0 deletions Gemfile_next.lock
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ GEM
railties (>= 4.2, < 7)
sprockets (>= 3.0, < 5)
tilt
angular_rails_csrf (4.2.0)
railties (>= 3, < 7)
angularjs-file-upload-rails (2.4.1)
angularjs-rails (1.5.5)
arel (7.1.4)
Expand Down Expand Up @@ -556,6 +558,7 @@ DEPENDENCIES
acts_as_list (= 0.9.19)
andand
angular-rails-templates (>= 0.3.0)
angular_rails_csrf
angularjs-file-upload-rails (~> 2.4.1)
angularjs-rails (= 1.5.5)
atomic
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/admin/admin_ofn.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ angular.module("ofn.admin", [
"admin.taxons",
"infinite-scroll"
]).config ($httpProvider) ->
$httpProvider.defaults.headers.common["X-CSRF-Token"] = $("meta[name=csrf-token]").attr("content")
$httpProvider.defaults.headers.common["Accept"] = "application/json, text/javascript, */*"
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
angular.module("admin.indexUtils", ['admin.resources', 'ngSanitize', 'templates', 'admin.utils']).config ($httpProvider) ->
$httpProvider.defaults.headers.common["X-CSRF-Token"] = $("meta[name=csrf-token]").attr("content"); $httpProvider.defaults.headers.common["Accept"] = "application/json, text/javascript, */*";
$httpProvider.defaults.headers.common["Accept"] = "application/json, text/javascript, */*"
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
angular.module('admin.orderCycles', ['ngTagsInput', 'admin.indexUtils', 'admin.enterprises'])

.config ($httpProvider) ->
$httpProvider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content')

.directive 'datetimepicker', ($timeout, $parse) ->
require: "ngModel"
link: (scope, element, attrs, ngModel) ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
angular.module("admin.productImport", ["ngResource"]).config ($httpProvider) ->
$httpProvider.defaults.headers.common["X-CSRF-Token"] = $("meta[name=csrf-token]").attr("content")
$httpProvider.defaults.headers.common["Accept"] = "application/json, text/javascript, */*"
3 changes: 2 additions & 1 deletion app/assets/javascripts/admin/utils/utils.js.coffee
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
angular.module("admin.utils", ["templates", "ngSanitize"]).config ($httpProvider) -> $httpProvider.defaults.headers.common["X-CSRF-Token"] = $("meta[name=csrf-token]").attr("content"); $httpProvider.defaults.headers.common["Accept"] = "application/json, text/javascript, */*";
angular.module("admin.utils", ["templates", "ngSanitize"]).config ($httpProvider) ->
$httpProvider.defaults.headers.common["Accept"] = "application/json, text/javascript, */*"
1 change: 0 additions & 1 deletion app/assets/javascripts/darkswarm/darkswarm.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ window.Darkswarm = angular.module("Darkswarm", [
'angularFileUpload',
'angularSlideables'
]).config ($httpProvider, $tooltipProvider, $locationProvider, $anchorScrollProvider) ->
$httpProvider.defaults.headers['common']['X-CSRF-Token'] = $('meta[name="csrf-token"]').attr('content')
$httpProvider.defaults.headers['common']['X-Requested-With'] = 'XMLHttpRequest'
$httpProvider.defaults.headers.common.Accept = "application/json, text/javascript, */*"

Expand Down

0 comments on commit 0f92b3c

Please sign in to comment.