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

This commit is contained in:
2024-09-01 21:35:35 +03:00
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)