There are several ways of doing this. I would recommend moving the logic to relevant view module.
In the below example I make the assumption that you continue to assign breadcrumbs in your other controllers as :breadcrumbs
, and just want to catch the Pow registration and session controllers (untested code, from the top of my head):
defmodule MyAppWeb.LayoutView do
use MyAppWeb, :view
alias MyAppWeb.Router.Helpers, as: Routes
@spec breadcrumbs(Plug.Conn.t()) :: [{binary(), binary()}]
def breadcrumbs(%{assigns: %{breadcrumbs: breadcrumbs}}), do: breadcrumbs
def breadcrumbs(%{private: %{phoenix_controller: Pow.Phoenix.RegistrationController, phoenix_action: :new}}), do: [{"Sign up", Routes.pow_registration_path(conn, :new)}]
def breadcrumbs(%{private: %{phoenix_controller: Pow.Phoenix.SessionController, phoenix_action: :new}}), do: [{"Sign in", Routes.pow_session_path(conn, :new)}]
def breadcrumbs(_conn), do: []
end
Now you just call breadcrumbs(@conn)
in your layout template (or partial) to fetch the list.
Edit: If a user inputs an invalid password the breadcrumbs in the above example will be empty. You can either change the pattern matching to handle multiple actions for the controller:
def breadcrumbs(%{private: %{phoenix_controller: Pow.Phoenix.SessionController, phoenix_action: action}}) when action in [:new, :create], do: [{"Sign in", Routes.pow_session_path(conn, :new)}]
Or you could even just use the view and template instead of controller and action:
def breacrumbs(%{private: %{phoenix_view: Pow.Phoenix.RegistrationView, phoenix_template: "new.html"}})), do: [{"Sign in", Routes.pow_session_path(conn, :new)}]