I need the following functions for almost all controllers. Does Elixir have an ApplicationController module?
Where should we put them?
def redirect_if_unauthorized(conn = %Plug.Conn{assigns: %{authorized: false}}, opts) do conn |> put_flash(:error, "You can't access that page!") |> redirect(to: "/") |> halt end def redirect_if_unauthorized(conn = %Plug.Conn{assigns: %{authorized: true}}, opts), do: conn
source share