Skip to content

Commit

Permalink
add email to auth buttons page for #63
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed May 1, 2020
1 parent d1ab73f commit 78ded7c
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 5 deletions.
5 changes: 5 additions & 0 deletions lib/auth/person.ex
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ defmodule Auth.Person do
end
end

def login_register_changeset() do
%Person{}
|> cast(%{}, [:email])
end

@doc """
`transform_github_profile_data_to_person/1` transforms the profile data
received from invoking `ElixirAuthGithub.github_auth/1`
Expand Down
11 changes: 10 additions & 1 deletion lib/auth_web/controllers/auth_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,17 @@ defmodule AuthWeb.AuthController do
handler(conn, person, state)
end

def login_register_handler(conn, params) do
IO.inspect(params, label: "params")

# def email_password_handler(conn, params) do
conn
|> put_resp_content_type("text/html")
|> send_resp(200, "login_register_handler")
|> halt()
end


# def email_handler(conn, params) do
#
# # GOTO: https://toranbillups.com/blog/archive/2018/11/18/implementing-basic-authentication/
# end
Expand Down
9 changes: 8 additions & 1 deletion lib/auth_web/controllers/page_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ defmodule AuthWeb.PageController do
oauth_github_url = ElixirAuthGithub.login_url(%{scopes: ["user:email"], state: state})
oauth_google_url = ElixirAuthGoogle.generate_oauth_url(conn, state)

changeset = Auth.Person.login_register_changeset()
# Map.put(assigns, :action,
# Routes.apikey_path(@conn, :create))
conn = assign(conn, :action,
Routes.auth_path(conn, :login_register_handler))

render(conn, "index.html",
oauth_github_url: oauth_github_url,
oauth_google_url: oauth_google_url
oauth_google_url: oauth_google_url,
changeset: changeset
)
end

Expand Down
1 change: 1 addition & 0 deletions lib/auth_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ defmodule AuthWeb.Router do
get "/", PageController, :index
get "/auth/github/callback", AuthController, :github_handler
get "/auth/google/callback", AuthController, :google_handler
post "/people/register", AuthController, :login_register_handler
end


Expand Down
2 changes: 0 additions & 2 deletions lib/auth_web/templates/apikey/show.html.eex
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


<div class="f3 w-60 center">
<h1>Your AUTH_API_KEY</h1>

Expand Down
22 changes: 21 additions & 1 deletion lib/auth_web/templates/page/index.html.eex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="phx-hero w-80 center">
<h1 class="center tc">Please Sign in to Continue</h1>
<p class="center tc">Login using your GitHub or Google Account: </p>
<p class="center tc f3">Use your GitHub or Google Account: </p>

<div style="display:flex; flex-direction:column; width:22em; margin: 20px auto;">
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap">
Expand Down Expand Up @@ -43,6 +43,26 @@
</div>
</a>
<div>

<div class="center">
<p class="center tc pt2 f3"><u>Or</u> use your email address: </p>

<%= form_for @changeset, @action, fn f -> %>
<%= text_input f, :email, class:
"db w-100 mt2 pa2 ba b--dark-grey f3",
placeholder: "your@email.com"%>
<%= error_tag f, :email %>
<br />

<%= submit "Login / Register",
class: "pointer br2 ba b--dark-green bg-green white pa3 ml1 mv1 f3
shadow-hover bg-animate hover-bg-dark-green border-box no-underline db",
style: "margin:0 auto;"
%>
<% end %>


</div>
</div>
<!-- Wake the Email Heroku App github.com/dwyl/auth/issues/50 -->
<img src="https://dwylmail.herokuapp.com/pixel" />

0 comments on commit 78ded7c

Please sign in to comment.