Matteo Scandolo | 889ced3 | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 1 | (function() { |
| 2 | 'use strict'; |
| 3 | |
Matteo Scandolo | 89b179c | 2016-03-24 11:38:50 -0700 | [diff] [blame] | 4 | console.log('SetCSRFToken'); |
| 5 | |
Matteo Scandolo | 889ced3 | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 6 | angular |
| 7 | .module('xos.helpers') |
| 8 | .factory('SetCSRFToken', setCSRFToken); |
| 9 | |
Matteo Scandolo | d3de390 | 2015-11-25 12:08:41 -0800 | [diff] [blame] | 10 | function setCSRFToken($cookies) { |
Matteo Scandolo | 889ced3 | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 11 | return { |
| 12 | request: function(request){ |
| 13 | if(request.method !== 'GET'){ |
| 14 | request.headers['X-CSRFToken'] = $cookies.get('xoscsrftoken'); |
| 15 | } |
| 16 | return request; |
| 17 | } |
| 18 | }; |
| 19 | } |
Matteo Scandolo | d3de390 | 2015-11-25 12:08:41 -0800 | [diff] [blame] | 20 | })(); |