blob: f3a234e8bb123dafd9409683094d5ef635630b65 [file] [log] [blame]
Matteo Scandolo817386b2015-11-04 16:07:09 +01001(function() {
2 'use strict';
3
Matteo Scandolo8420f622016-03-24 11:38:50 -07004 console.log('SetCSRFToken');
5
Matteo Scandolo817386b2015-11-04 16:07:09 +01006 angular
7 .module('xos.helpers')
8 .factory('SetCSRFToken', setCSRFToken);
9
Matteo Scandolo9323b1b2015-11-25 12:08:41 -080010 function setCSRFToken($cookies) {
Matteo Scandolo817386b2015-11-04 16:07:09 +010011 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 Scandolo9323b1b2015-11-25 12:08:41 -080020})();