Matteo Scandolo | 817386b | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 1 | (function() { |
| 2 | 'use strict'; |
| 3 | |
Matteo Scandolo | 8420f62 | 2016-03-24 11:38:50 -0700 | [diff] [blame] | 4 | console.log('SetCSRFToken'); |
| 5 | |
Matteo Scandolo | 817386b | 2015-11-04 16:07:09 +0100 | [diff] [blame] | 6 | angular |
| 7 | .module('xos.helpers') |
| 8 | .factory('SetCSRFToken', setCSRFToken); |
| 9 | |
Matteo Scandolo | 9323b1b | 2015-11-25 12:08:41 -0800 | [diff] [blame] | 10 | function setCSRFToken($cookies) { |
Matteo Scandolo | 817386b | 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 | 9323b1b | 2015-11-25 12:08:41 -0800 | [diff] [blame] | 20 | })(); |