class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
  before_action :authenticate_user!, unless: -> { devise_controller? || is_a?(KioskController) }

  rescue_from CanCan::AccessDenied do |exception|
    respond_to do |format|
      format.json { head :forbidden, content_type: 'text/html' }
      format.html { redirect_to main_app.root_url, notice: exception.message }
      format.js   { head :forbidden, content_type: 'text/html' }
    end
  end

  rescue_from SocketError do
    respond_to do |format|
      format.html { render file: "#{Rails.root}/public/500", layout: false, status: :error }
    end
  end
end
