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