mirror of
https://github.com/plausible/analytics.git
synced 2024-12-01 03:48:35 +03:00
22 lines
404 B
Elixir
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
|