module Admin
  class YoutubeController < Admin::BaseController
    def platform
      if ENV["YOUTUBE_CLIENT_ID"].blank?
        redirect_to admin_root_path, alert: "Configura YOUTUBE_CLIENT_ID e YOUTUBE_CLIENT_SECRET in .env"
        return
      end

      state = Youtube::OauthState.for_platform(admin_id: current_admin_account.id)
      redirect_to Youtube::OauthUrl.build(state: state), allow_other_host: true
    end
  end
end
