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_team_owner!(team)
      membership = current_user.user_teams.find_by(team: team)
      redirect_to public_prezzi_path, alert: "Accesso non consentito" unless membership&.role == "owner"
    end
  end
end
