analytics/lib/plausible_web/plugs/require_account.ex
Uku Taht aa7ae87811
Onboarding UX improvements (#441)
* WIP

* Actually activate the user

* Send email verification codes

* Send activation code with email

* Only show onboarding steps during first site creation

* Add worker to config

* Consistent form styles

* Send welcome email when user activates account

* Add changelog entry

* Use https in new site form

* Correct spelling in email
2020-12-15 11:30:45 +02:00

27 lines
510 B
Elixir

defmodule PlausibleWeb.RequireAccountPlug do
import Plug.Conn
def init(options) do
options
end
def call(conn, _opts) do
user = conn.assigns[:current_user]
cond do
is_nil(user) ->
Plug.Conn.put_session(conn, :login_dest, conn.request_path)
|> Phoenix.Controller.redirect(to: "/login")
|> halt
not user.email_verified ->
conn
|> Phoenix.Controller.redirect(to: "/activate")
|> halt
true ->
conn
end
end
end