How to subscribe a user to his own private channel server-side based on socket.assigns:[user] only

I have this in the channel module:

  def join("room:" <> user_id, _params, socket) do
    {user_id, _} = Integer.parse(user_id)
    %{id: id} = socket.assigns[:user]
    case id == user_id do
      true ->
        {:ok, socket}
      false ->
        {:error, "This is not your solo channel!"}
    end
  end

And this inside user_socket.ex:

  def connect(%{"token" => token}, socket) do
    case Phauxth.Token.verify(socket, token, 86400) do
      {:ok, user_id} ->
        socket = assign(socket, :user, Repo.get!(Onlist.Accounts.User, user_id))
        {:ok, socket}
      {:error, _} ->
        IO.puts "error"
        :error
    end
  end

This is working fine, my question, is ti possible to subscribe a user to his own channel based on the socket socket.assigns:[user] without the need of him sending his user_id to def join("room:" <> user_id, _params, socket) do from JS?

How to rewrite the join method and make it extract the user_id from the socket and subscribe him to room:user_id?

If You don’t send that id, that would be like subscribing to room topic, not room:id topic. IMHO It should be better to have a unique channel per user. And often client side knows about who is connected.