analytics/lib/plausible_web/plugs/upgrade_billing_plug.ex
Preslav Rachev 431c02ad58
#332: Refactor stats controller (#337)
* #332: Refactor stats controller

* Simplify the conditional logic
2020-10-02 12:02:32 +03:00

20 lines
371 B
Elixir

defmodule PlausibleWeb.UpgradeBillingPlug do
import Phoenix.Controller
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")
else
conn
end
end
end