Ash FrameworkAF
Ash Framework3y ago
116 replies
richaard0

Multitenancy and different Liveviews

So this might not be directly related to AshAuthentication, but somebody could help me figure out what's going.

I'm still super new to Elixir and Phoenix so bear with me haha

Continuing from the discussion above with multitenancy
I have a live_view being rendered normally from the router, but this one also has a child live_view rendered with live_render like so:

<%= live_render(@socket, MyAppWeb.Messaging,
  id: "messaging",
  sticky: true
) %>
<div class="flex flex-grow flex-col">
  <.live_component
    module={MyAppWeb.Components.AppHeader}
    id="header"
    page_title={@page_title}
    current_user={@current_user}
  />
  <div class="p-2">
    <p class="text-2xl">Component here</p>
  </div>
</div>


When I log in, I automatically gets logged out.

When I inspect the socket and session of the messaging live_view, on the second render, there aren't any users or tenant.

In messaging.ex, I have the following:

on_mount {MyAppWeb.UserAuth, :current_user}

which points to the following:
  def on_mount(:current_user, _params, _session, socket) do
    {:cont, Phoenix.Component.assign_new(socket, :current_user, &get_tenant/1)}
  end


Is there anything I'm missing?

If I comment out the multitenancy part out, I don't encounter the isssue, same thing if I comment out the messaging live view
Was this page helpful?