* Update Travis.yml * Update README * Update README * Adjust test to not rely on env vars * Update encryption * Refactor * Update env key * Stub AWS calls * Create ApplicationConfig * Fix specs * Fix lint * Update ApplicationConfig * Remove travis env vars * Fix lint * Extend character limit to 100 * Add env to travis * Take out auto-restart after deploy * Immediately discarded test cache * Stub GA in request specs * Stub Pusher * Fix broken specs * Update fixture * Add CodeClimate id * Change CodeClimate key * Remove merge mistakes * WIP * Add Envied gem & Change README * Add missing keys * Add missing key * Update fixture * Fix broken spec * Add Slack Notification for Travis * Fix wording * Fix typo
24 lines
928 B
Text
24 lines
928 B
Text
function getCsrfToken() {
|
|
var promise = new Promise(function (resolve, reject) {
|
|
var i = 0;
|
|
var waitingOnCSRF = setInterval(function () {
|
|
var metaTag = document.querySelector("meta[name='csrf-token']");
|
|
i++;
|
|
if (metaTag) {
|
|
clearInterval(waitingOnCSRF);
|
|
var authToken = metaTag.getAttribute("content");
|
|
return resolve(authToken);
|
|
} else if (i === 1000) {
|
|
clearInterval(waitingOnCSRF);
|
|
var airbrake = new airbrakeJs.Client({projectId: 1, projectKey: '<%=ApplicationConfig["AIRBRAKE_API_KEY"]%>'});
|
|
airbrake.addFilter(function(notice) {
|
|
notice.context.environment = "<%= Rails.env %>";
|
|
return notice;
|
|
});
|
|
airbrake.notify("Could no locate CSRF metatag" + JSON.stringify(localStorage.current_user));
|
|
return reject("Could not locate CSRF meta tag on the page.");
|
|
}
|
|
}, 5);
|
|
});
|
|
return promise;
|
|
}
|