From 786525b1ab208a5b149380fabfce3f6fbe0de10c Mon Sep 17 00:00:00 2001 From: SimonLab Date: Thu, 3 Mar 2022 14:06:26 +0000 Subject: [PATCH 1/3] create labels and checkboxes for auth methods --- lib/auth_web/templates/app/form.html.eex | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/auth_web/templates/app/form.html.eex b/lib/auth_web/templates/app/form.html.eex index 76b51489..7dcb731c 100644 --- a/lib/auth_web/templates/app/form.html.eex +++ b/lib/auth_web/templates/app/form.html.eex @@ -20,6 +20,19 @@ placeholder: "The URL of your app e.g: http://localhost:4000 or dwyl.com" %> <%= error_tag f, :url %> + + <%= label do %> + <%= checkbox f, :method, value: :github %> + Github + <% end %> + <%= label do %> + <%= checkbox f, :method, value: :google %> + Google + <% end %> + <%= label do %> + <%= checkbox f, :method, value: :email %> + Email/Password + <% end %>
<%= submit "Save", From 1fca726a414e3e02667b5c6be3f161ec9f1dc081 Mon Sep 17 00:00:00 2001 From: SimonLab Date: Wed, 9 Mar 2022 10:57:29 +0000 Subject: [PATCH 2/3] use Config instead of Mix.Config module --- config/config.exs | 4 ++-- config/dev.exs | 2 +- config/test.exs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/config.exs b/config/config.exs index ed2f24eb..bfb823e5 100644 --- a/config/config.exs +++ b/config/config.exs @@ -5,7 +5,7 @@ # is restricted to this project. # General application configuration -use Mix.Config +import Config config :auth, ecto_repos: [Auth.Repo] @@ -44,4 +44,4 @@ config :esbuild, ] config :auth_plug, - api_key: System.get_env("AUTH_API_KEY") \ No newline at end of file + api_key: System.get_env("AUTH_API_KEY") diff --git a/config/dev.exs b/config/dev.exs index 2cee784e..7f616d82 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -1,4 +1,4 @@ -use Mix.Config +import Config # Configure your database config :auth, Auth.Repo, diff --git a/config/test.exs b/config/test.exs index 19da02e0..d3ebd953 100644 --- a/config/test.exs +++ b/config/test.exs @@ -1,4 +1,4 @@ -use Mix.Config +import Config # Configure your database config :auth, Auth.Repo, From 1863c776d7cd1108f4c6f6fc18ade204c9e61cde Mon Sep 17 00:00:00 2001 From: SimonLab Date: Mon, 14 Mar 2022 09:21:52 +0000 Subject: [PATCH 3/3] log params for auth method --- lib/auth_web/controllers/app_controller.ex | 39 +++++++++++++++++----- lib/auth_web/templates/app/form.html.eex | 6 ++-- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/lib/auth_web/controllers/app_controller.ex b/lib/auth_web/controllers/app_controller.ex index ba28d847..84dbeeb1 100644 --- a/lib/auth_web/controllers/app_controller.ex +++ b/lib/auth_web/controllers/app_controller.ex @@ -12,23 +12,46 @@ defmodule AuthWeb.AppController do end def create(conn, %{"app" => app_params}) do + IO.inspect(app_params) + attrs = Map.merge(app_params, %{ "person_id" => conn.assigns.person.id, "status" => 3 }) - case App.create_app(attrs) do - {:ok, app} -> - conn - |> put_flash(:info, "App created successfully.") - |> redirect(to: Routes.app_path(conn, :show, app)) + changeset = App.change_app(%App{}) + render(conn, "new.html", changeset: changeset) + + # case App.create_app(attrs) do + # {:ok, app} -> + # conn + # |> put_flash(:info, "App created successfully.") + # |> redirect(to: Routes.app_path(conn, :show, app)) - {:error, %Ecto.Changeset{} = changeset} -> - render(conn, "new.html", changeset: changeset) - end + # {:error, %Ecto.Changeset{} = changeset} -> + # render(conn, "new.html", changeset: changeset) + # end end + # def create(conn, %{"app" => app_params}) do + # attrs = + # Map.merge(app_params, %{ + # "person_id" => conn.assigns.person.id, + # "status" => 3 + # }) + + # case App.create_app(attrs) do + # {:ok, app} -> + # conn + # |> put_flash(:info, "App created successfully.") + # |> redirect(to: Routes.app_path(conn, :show, app)) + + # {:error, %Ecto.Changeset{} = changeset} -> + # render(conn, "new.html", changeset: changeset) + # end + # end + def show(conn, %{"id" => id}) do app = App.get_app!(id) #  restrict viewership to owner||admin https://github.com/dwyl/auth/issues/99 diff --git a/lib/auth_web/templates/app/form.html.eex b/lib/auth_web/templates/app/form.html.eex index 7dcb731c..ce7f658e 100644 --- a/lib/auth_web/templates/app/form.html.eex +++ b/lib/auth_web/templates/app/form.html.eex @@ -22,15 +22,15 @@ <%= error_tag f, :url %> <%= label do %> - <%= checkbox f, :method, value: :github %> + <%= checkbox f, :github%> Github <% end %> <%= label do %> - <%= checkbox f, :method, value: :google %> + <%= checkbox f, :google%> Google <% end %> <%= label do %> - <%= checkbox f, :method, value: :email %> + <%= checkbox f, :email%> Email/Password <% end %>