// jscs:disable requireCamelCaseOrUpperCaseIdentifiers

(function (Twitch, $) {
  $(document).on('click', "a.js-logout_link", function (e) {
    e.preventDefault();
    Twitch.user(function (userData) {
      var csrf = $("<input>").attr({
        type: "hidden",
        name: "authenticity_token",
        value: userData.csrf_token
      });
      $("#logout_form").append(csrf).submit();
    }, function () {
      $("#logout_form").submit();
    });
  });
})(Twitch, jQuery);
