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