Skip to content

Commit

Permalink
revert to contorller, update sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Toby Archer committed Aug 25, 2023
1 parent a18a92f commit 05efa59
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 13 deletions.
3 changes: 1 addition & 2 deletions elixir-ory-network/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import Config
config :example,
ecto_repos: [Example.Repo]

config :example, Example.Repo,
database: "priv/database.db"
config :example, Example.Repo, database: "priv/database.db"

# Configures the endpoint
config :example, ExampleWeb.Endpoint,
Expand Down
5 changes: 3 additions & 2 deletions elixir-ory-network/config/dev.exs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import Config


# Configure your Ory Network URL
config :ory_client,
:base_url, "http://localhost:3000/.ory" # Via ory proxy
# Via ory proxy
:base_url,
"http://localhost:3000/.ory"

# For development, we disable any cache and enable
# debugging and code reloading.
Expand Down
1 change: 0 additions & 1 deletion elixir-ory-network/lib/example_web.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ defmodule ExampleWeb do
import Plug.Conn
import ExampleWeb.Gettext


unquote(verified_routes())
end
end
Expand Down
4 changes: 3 additions & 1 deletion elixir-ory-network/lib/example_web/components/flow.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ defmodule ExampleWeb.Flow do
# TODO(@tobbbles): Figure out if this can be dynamically set up as a type union from Ory LoginFlow and RegistratinFlow
attr :flow, :map, required: true

def flow(assigns) do
def flow(assigns) when not is_nil(assigns.flow) do
IO.inspect(assigns)

~H"""
<.ui_message_group flow={@flow} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
</h2>

<ExampleWeb.Flow.flow flow={@flow} />

Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
</h2>

<ExampleWeb.Flow.flow flow={@flow} />

1 change: 0 additions & 1 deletion elixir-ory-network/lib/example_web/helpers.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
defmodule ExampleWeb.Helpers do

@doc """
Helper function to format request cookie map into string
"""
Expand Down
5 changes: 3 additions & 2 deletions elixir-ory-network/lib/example_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ defmodule ExampleWeb.Router do
pipe_through(:browser)

get("/", PageController, :home)

end

scope "/auth", ExampleWeb do
pipe_through(:browser)

get("/login", AuthController, :login)
get("/register", AuthController, :registration)
get "/login", AuthController, :login
get "/register", AuthController, :registration
end

# Other scopes may use custom stacks.
Expand Down
2 changes: 1 addition & 1 deletion elixir-ory-network/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ defmodule Example.MixProject do

# {:ory_client, "~> 1.1.42"}
{:ory_client,
git: "https://github.com/tobbbles/sdk.git", ref: "master", subdir: "clients/client/elixir"},
git: "https://github.com/tobbbles/sdk.git", ref: "master", subdir: "clients/client/elixir"}
]
end

Expand Down
2 changes: 1 addition & 1 deletion elixir-ory-network/mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"gettext": {:hex, :gettext, "0.22.3", "c8273e78db4a0bb6fba7e9f0fd881112f349a3117f7f7c598fa18c66c888e524", [:mix], [{:expo, "~> 0.4.0", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "935f23447713954a6866f1bb28c3a878c4c011e802bcd68a726f5e558e4b64bd"},
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
"mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"},
"ory_client": {:git, "https://github.com/tobbbles/sdk.git", "0bb32fa34f2cb62b27be7984a9f7ae6c468206c8", [ref: "master", subdir: "clients/client/elixir"]},
"ory_client": {:git, "https://github.com/tobbbles/sdk.git", "c182ac6820a1620e115f40268ff0775cc4a2fc0c", [ref: "master", subdir: "clients/client/elixir"]},
"phoenix": {:hex, :phoenix, "1.7.6", "61f0625af7c1d1923d582470446de29b008c0e07ae33d7a3859ede247ddaf59a", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "f6b4be7780402bb060cbc6e83f1b6d3f5673b674ba73cc4a7dd47db0322dfb88"},
"phoenix_ecto": {:hex, :phoenix_ecto, "4.4.2", "b21bd01fdeffcfe2fab49e4942aa938b6d3e89e93a480d4aee58085560a0bc0d", [:mix], [{:ecto, "~> 3.5", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "70242edd4601d50b69273b057ecf7b684644c19ee750989fd555625ae4ce8f5d"},
"phoenix_html": {:hex, :phoenix_html, "3.3.1", "4788757e804a30baac6b3fc9695bf5562465dd3f1da8eb8460ad5b404d9a2178", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "bed1906edd4906a15fd7b412b85b05e521e1f67c9a85418c55999277e553d0d3"},
Expand Down
108 changes: 108 additions & 0 deletions elixir-ory-network/test/example_web/live/auth_live_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
defmodule ExampleWeb.AuthLiveTest do
use ExampleWeb.ConnCase

import Phoenix.LiveViewTest
import Example.AccountsFixtures

@create_attrs %{}
@update_attrs %{}
@invalid_attrs %{}

defp create_auth(_) do
auth = auth_fixture()
%{auth: auth}
end

describe "Index" do
setup [:create_auth]

test "lists all auth", %{conn: conn} do
{:ok, _index_live, html} = live(conn, ~p"/auth")

assert html =~ "Listing Auth"
end

test "saves new auth", %{conn: conn} do
{:ok, index_live, _html} = live(conn, ~p"/auth")

assert index_live |> element("a", "New Auth") |> render_click() =~
"New Auth"

assert_patch(index_live, ~p"/auth/new")

assert index_live
|> form("#auth-form", auth: @invalid_attrs)
|> render_change() =~ "can&#39;t be blank"

assert index_live
|> form("#auth-form", auth: @create_attrs)
|> render_submit()

assert_patch(index_live, ~p"/auth")

html = render(index_live)
assert html =~ "Auth created successfully"
end

test "updates auth in listing", %{conn: conn, auth: auth} do
{:ok, index_live, _html} = live(conn, ~p"/auth")

assert index_live |> element("#auth-#{auth.id} a", "Edit") |> render_click() =~
"Edit Auth"

assert_patch(index_live, ~p"/auth/#{auth}/edit")

assert index_live
|> form("#auth-form", auth: @invalid_attrs)
|> render_change() =~ "can&#39;t be blank"

assert index_live
|> form("#auth-form", auth: @update_attrs)
|> render_submit()

assert_patch(index_live, ~p"/auth")

html = render(index_live)
assert html =~ "Auth updated successfully"
end

test "deletes auth in listing", %{conn: conn, auth: auth} do
{:ok, index_live, _html} = live(conn, ~p"/auth")

assert index_live |> element("#auth-#{auth.id} a", "Delete") |> render_click()
refute has_element?(index_live, "#auth-#{auth.id}")
end
end

describe "Show" do
setup [:create_auth]

test "displays auth", %{conn: conn, auth: auth} do
{:ok, _show_live, html} = live(conn, ~p"/auth/#{auth}")

assert html =~ "Show Auth"
end

test "updates auth within modal", %{conn: conn, auth: auth} do
{:ok, show_live, _html} = live(conn, ~p"/auth/#{auth}")

assert show_live |> element("a", "Edit") |> render_click() =~
"Edit Auth"

assert_patch(show_live, ~p"/auth/#{auth}/show/edit")

assert show_live
|> form("#auth-form", auth: @invalid_attrs)
|> render_change() =~ "can&#39;t be blank"

assert show_live
|> form("#auth-form", auth: @update_attrs)
|> render_submit()

assert_patch(show_live, ~p"/auth/#{auth}")

html = render(show_live)
assert html =~ "Auth updated successfully"
end
end
end

0 comments on commit 05efa59

Please sign in to comment.