Skip to content

Commit

Permalink
💯 #42
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Apr 26, 2020
1 parent 78ac642 commit bed4d82
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
18 changes: 9 additions & 9 deletions lib/auth_web/controllers/page_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ defmodule AuthWeb.PageController do
end

# https://github.com/dwyl/auth/issues/46
def admin(conn, params) do
# IO.inspect(conn.req_headers, label: "conn.req_headers")
IO.inspect(params, label: "params")
IO.inspect(conn.assigns)

conn
|> put_view(AuthWeb.PageView)
|> render(:welcome)
end
# def admin(conn, params) do
# # IO.inspect(conn.req_headers, label: "conn.req_headers")
# IO.inspect(params, label: "params")
# IO.inspect(conn.assigns)
#
# conn
# |> put_view(AuthWeb.PageView)
# |> render(:welcome)
# end

def get_referer(conn) do
# https://stackoverflow.com/questions/37176911/get-http-referrer
Expand Down
13 changes: 0 additions & 13 deletions test/auth_web/controllers/auth_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,4 @@ defmodule AuthWeb.AuthControllerTest do
assert html_response(conn, 200) =~ "google account"
# assert html_response(conn, 302) =~ "redirected"
end

# test "handler/3 show welcome page", %{conn: conn} do
#
# person = Auth.Person.create_person(%{
# email: "[email protected]", givenName: "McTestin"
# })
# IO.inspect(person, label: "person")
#
# conn = AuthPlug.create_jwt_session(conn, %{email: person.email, id: person.id})
# conn = AuthWeb.AuthController.handler(conn, person, nil)
# IO.inspect(conn, label: "conn")
# # assert html_response(conn, 302) =~ "redirected"
# end
end
16 changes: 16 additions & 0 deletions test/auth_web/controllers/page_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,20 @@ defmodule AuthWeb.PageControllerTest do

assert conn.resp_body =~ "state=http://localhost/admin"
end

test "google_handler/2 show welcome (state=nil) > handler/3", %{conn: conn} do
data = %{
email: "[email protected]",
givenName: "McTestin",
picture: "https://youtu.be/naoknj1ebqI",
auth_provider: "google"
}
person = Auth.Person.create_person(data) # |> IO.inspect(label: "person")
conn = AuthPlug.create_jwt_session(conn, Map.merge(data, %{id: person.id}))
conn = get(conn, "/auth/google/callback",
%{code: "234", state: nil})

assert html_response(conn, 200) =~ "google account"
# assert html_response(conn, 302) =~ "redirected"
end
end

0 comments on commit bed4d82

Please sign in to comment.