module Public
  class WebBaseController < SiteBaseController
    protect_from_forgery with: :exception

    private

    def require_login!
      return if logged_in?

      redirect_to public_login_path, alert: "Accedi per continuare"
    end

    def require_club_owner!(club)
      redirect_to public_prezzi_path, alert: "Accesso non consentito" unless club.owned_by?(current_user)
    end

    def require_club_owner_for_team!(team)
      redirect_to public_prezzi_path, alert: "Accesso non consentito" unless team.club&.owned_by?(current_user)
    end
  end
end
