2018-11-21 11:08:53 +01:00
|
|
|
'use strict';
|
2015-05-05 03:10:25 +02:00
|
|
|
|
2018-10-25 16:50:16 +02:00
|
|
|
Application.Services.service('CSRF', ['$cookies',
|
2018-11-27 15:16:23 +01:00
|
|
|
function ($cookies) {
|
|
|
|
return ({
|
2018-10-25 16:51:20 +02:00
|
|
|
setMetaTags () {
|
2018-10-25 16:50:16 +02:00
|
|
|
if (angular.element('meta[name="csrf-param"]').length === 0) {
|
2018-11-21 11:08:53 +01:00
|
|
|
angular.element('head').append('<meta name="csrf-param" content="authenticity_token">');
|
2018-11-27 15:16:23 +01:00
|
|
|
angular.element('head').append(`<meta name="csrf-token" content="${$cookies.get('XSRF-TOKEN')}">`);
|
2018-10-25 16:50:16 +02:00
|
|
|
} else {
|
2018-11-27 15:16:23 +01:00
|
|
|
angular.element('meta[name="csrf-token"]').replaceWith(`<meta name="csrf-token" content="${$cookies.get('XSRF-TOKEN')}">`);
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
|
|
|
}
|
2018-11-27 15:16:23 +01:00
|
|
|
});
|
|
|
|
}
|
2018-11-21 11:08:53 +01:00
|
|
|
]);
|