 defmodule OntagCoreWeb.MeController do
   use OntagCoreWeb, :controller
+  alias OntagCore.Repo
+  alias OntagCore.Accounts.MediumCredential
 
   plug OntagCoreWeb.Authentication when action in [:index, :add_medium_credential]
   action_fallback OntagCoreWeb.FallbackController

      %{
        id: user.id,
        name: user.name,
        username: user.username
      }
    )
  end

  def index(conn, _) do
    user =
      conn.assigns[:current_user]
      |> Repo.preload(:medium_credential)

    mc =
      case user.medium_credential do
        m = %MediumCredential{} ->
          %{
            username: m.username,
            name: m.name,
            url: m.url,
            medium_id: m.medium_id
          }

        _ ->
          %{}
      end

    conn
    |> put_status(:ok)
