1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-02 13:24:20 +01:00
fab-manager/app/assets/javascripts/services/csrf.js

17 lines
591 B
JavaScript
Raw Normal View History

2018-11-21 11:08:53 +01:00
'use strict';
2015-05-05 03:10:25 +02:00
Application.Services.service('CSRF', ['$cookies',
2018-11-27 15:16:23 +01:00
function ($cookies) {
return ({
setMetaTags () {
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')}">`);
} 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-11-27 15:16:23 +01:00
});
}
2018-11-21 11:08:53 +01:00
]);