/*global cookie*/
(function ($) {
  Twitch.user(function (info) {
    Twitch.storage.set("csrf_token", info['csrf_token']);
  });

  $.ajaxPrefilter(function (options, originalOptions, jqXHR) {
    csrf_token = Twitch.storage.get("csrf_token")
    if (!options.crossDomain && csrf_token) {
      jqXHR.setRequestHeader('X-CSRF-Token', csrf_token);
    }
  });
})(jQuery);
