implement step 2 stuff

This commit is contained in:
2021-12-04 16:57:47 -05:00
parent d32dc8c2cb
commit 5de53e23ea
14 changed files with 121 additions and 20 deletions

View File

@@ -7,7 +7,6 @@ defmodule EntenduWeb.AuthController do
plug Ueberauth
alias Ueberauth.Strategy.Helpers
alias Entendu.UserFromAuth
def delete(conn, _params) do

View File

@@ -33,8 +33,6 @@ defmodule EntenduWeb.LinkController do
link_params <- Params.to_map(changeset),
{:ok, %Link{} = link} <- Links.create_link(link_params) do
conn
|> put_status(:created)
|> assign(:link, link)
|> render("show_authorized.json", %{link: link})
end
end
@@ -43,8 +41,21 @@ defmodule EntenduWeb.LinkController do
render(conn, "for.html")
end
def for(_conn, %{username: _username, service: _service}) do
{:error, "not implemented"}
defparams(
second_step(%{
service: :string,
recipient: :string
})
)
def for(conn, %{link_id: link_id} = params) do
with %Changeset{valid?: true} = changeset <- first_step(params),
link_params <- Params.to_map(changeset),
%Link{} = link <- Links.get_link(link_id),
Links.update_link(link, link_params) do
conn
|> render("show_authorized.json", %{link: link})
end
end
def you_page(conn, _params) do

View File

@@ -15,9 +15,9 @@ defmodule EntenduWeb.LiveHelpers do
link: @link,
return_to: Routes.link_index_path(@socket, :index) %>
"""
def live_modal(socket, component, opts) do
def live_modal(_socket, component, opts) do
path = Keyword.fetch!(opts, :return_to)
modal_opts = [id: :modal, return_to: path, component: component, opts: opts]
live_component(socket, EntenduWeb.ModalComponent, modal_opts)
live_component(EntenduWeb.ModalComponent, modal_opts)
end
end

View File

@@ -1 +1 @@
<%= react_component("Components.JustPage") %>
<%= react_component("Components.JustPage", %{ csrf: Plug.CSRFProtection.get_csrf_token() }) %>

View File

@@ -1,6 +1,5 @@
defmodule EntenduWeb.LinkView do
use EntenduWeb, :view
alias EntenduWeb.LinkView
def render("show_authorized.json", %{link: link}) do
%{