analytics/lib/plausible_web/plugs/upgrade_billing_plug.ex

22 lines
404 B
Elixir
Raw Normal View History

defmodule PlausibleWeb.UpgradeBillingPlug do
import Phoenix.Controller
2020-11-26 17:01:14 +03:00
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")
2020-11-26 17:01:14 +03:00
|> halt
else
conn
end
end
end