Update the create link route to add the relationship to the user.

dev
KKlochko 8 months ago
parent 8d3d619e7c
commit f2fe354e43

@ -12,6 +12,12 @@ defmodule LinkShortenerWeb.Api.V1.LinkController do
end
def create(conn, %{"link" => link_params}) do
user = Guardian.Plug.current_resource(conn)
link_params =
link_params
|> Map.put("user_id", user.id)
with {:ok, %Link{} = link} <- Links.insert_one(link_params) do
conn
|> put_status(:created)

Loading…
Cancel
Save