analytics/lib/plausible_web/plugs/upgrade_billing_plug.ex
2020-11-26 16:01:14 +02:00

22 lines
404 B
Elixir

defmodule PlausibleWeb.UpgradeBillingPlug do
import Phoenix.Controller
import Plug.Conn
use Plausible.Repo
def init(options) do
options
end
def call(conn, _opts) do
user = conn.assigns[:current_user]
if user && Plausible.Billing.needs_to_upgrade?(conn.assigns[:current_user]) do
conn
|> redirect(to: "/settings")
|> halt
else
conn
end
end
end