I've tried a couple different iterations but I keep getting this error when compiling:
Routes.session_path/2 is undefined (module Routes is not available)
My Code:
defmodule Blackbook.Plugs.RequireAuth do
import Plug.Conn
import Phoenix.Controller
alias Blackbook.Router.Helpers, as: Routes
def init(_params) do
end
def call(conn, _params) do
if conn.assigns[:current_user] do
conn
else
conn
|> put_flash(:error, "You must be logged in.")
|> redirect(to: Routes.session_path(conn, :new))
|> halt()
end
end
end
It's a little different in Phoenix 1.4, tried referring to documentation here https://hexdocs.pm/phoenix/Phoenix.Router.html but still no luck.