Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select auth methods #185

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 31 additions & 8 deletions lib/auth_web/controllers/app_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions lib/auth_web/templates/app/form.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -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, :github%>
Github
<% end %>
<%= label do %>
<%= checkbox f, :google%>
Google
<% end %>
<%= label do %>
<%= checkbox f, :email%>
Email/Password
<% end %>

<div class="mt2 fr">
<%= submit "Save",
Expand Down