Matteo Scandolo | 817386b | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 1 | (function() { |
Matteo Scandolo | 2436e4d | 2016-01-28 11:05:15 -0800 | [diff] [blame] | 2 | 'use strict'; |
Matteo Scandolo | 817386b | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 3 | |
Matteo Scandolo | 2436e4d | 2016-01-28 11:05:15 -0800 | [diff] [blame] | 4 | angular |
| 5 | .module('xos.helpers') |
| 6 | .factory('SetCSRFToken', setCSRFToken); |
Matteo Scandolo | 817386b | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 7 | |
Matteo Scandolo | 2436e4d | 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 | 817386b | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 13 | } |
Matteo Scandolo | 2436e4d | 2016-01-28 11:05:15 -0800 | [diff] [blame] | 14 | return request; |
| 15 | } |
| 16 | }; |
| 17 | } |
Matteo Scandolo | 9323b1b | 2015-11-25 12:08:41 -0800 | [diff] [blame] | 18 | })(); |