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