Hello, i upgraded my application to phoenix 1.7.7 Now I implemented the authentication (created by phx generator). In my root layout I have access to the assign @current_user, but not in my application layouts. I already compared my code to a fresh generated project, but I can not find the difference.
This is an example of one of the controllers that has the assign in the root layout, but not in the application layout:
...
def live_view_admin do
quote do
use Phoenix.LiveView,
layout: {ClubWeb.Layouts, :admin}
unquote(html_helpers())
end
end
...
defmodule ClubWeb.Layouts do
use ClubWeb, :html
embed_templates "layouts/*"
end
defmodule ClubWeb.Admin.EventLive.Index do
use ClubWeb, :live_view_admin
alias Club.Events
alias Club.Events.Event
@impl true
def mount(_params, _session, socket) do
{:ok, stream(socket, :events, Events.list_events())}
end
@impl true
def handle_params(params, _url, socket) do
{:noreply, apply_action(socket, socket.assigns.live_action, params)}
end
defp apply_action(socket, :edit, %{"id" => id}) do
socket
|> assign(:page_title, "Edit Event")
|> assign(:event, Events.get_event!(id))
end
defp apply_action(socket, :new, _params) do
socket
|> assign(:page_title, "New Event")
|> assign(:event, %Event{})
end
defp apply_action(socket, :index, _params) do
socket
|> assign(:page_title, "Listing Events")
|> assign(:event, nil)
end
@impl true
def handle_info({ClubWeb.Admin.EventLive.FormComponent, {:saved, event}}, socket) do
{:noreply, stream_insert(socket, :events, event)}
end
@impl true
def handle_event("delete", %{"id" => id}, socket) do
event = Events.get_event!(id)
{:ok, _} = Events.delete_event(event)
{:noreply, stream_delete(socket, :events, event)}
end
end