Update the create link route to add the relationship to the user.
This commit is contained in:
@@ -12,6 +12,12 @@ defmodule LinkShortenerWeb.Api.V1.LinkController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create(conn, %{"link" => link_params}) do
|
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
|
with {:ok, %Link{} = link} <- Links.insert_one(link_params) do
|
||||||
conn
|
conn
|
||||||
|> put_status(:created)
|
|> put_status(:created)
|
||||||
|
|||||||
Reference in New Issue
Block a user