     |> render("error.json", reason: "User does not exist")
   end
 
-  defp delete_host_from_user(conn) do
+  defp handle_logout(conn) do
     user = Guardian.Plug.current_resource(conn)
+    host = Repo.get(Host, user.host_id)
+
+    # Publish 'REMOVE_USER' message to master node. After that, master node will
+    # publish message to the rest of nodes in cluster.
+    %{host: host, id: user.id}
+    |> publish_message("REMOVE_USER")
 
     User.host_changeset(user, %{host_id: nil})
     |> Repo.update!

    |> Guardian.revoke!

    conn
    |> delete_host_from_user
    |> put_status(:ok)
    |> render("delete.json", success: true)
  end

defmodule UserApp.SessionController do
  use UserApp.Web, :controller

  alias UserApp.{Auth, User, Repo, Host}

  def index(conn, _params) do
    users =
