Skip to content

Commit

Permalink
Merge pull request #12 from dwyl/id-person-#7
Browse files Browse the repository at this point in the history
send back id_person with /person/info endpoint
  • Loading branch information
nelsonic authored Mar 6, 2020
2 parents 715e727 + d4dc62f commit 48c5450
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule AuthMvpWeb.PersonController do
def index(conn, _params) do
person = AuthMvp.People.get_person_by_email(conn.assigns.claims.email)

render(conn, "index.json", person: %{email: person.email})
render(conn, "index.json", person: %{id_person: person.id, email: person.email})
end

end
11 changes: 7 additions & 4 deletions test/auth_mvp_web/controllers/person_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ defmodule AuthMvpWeb.PersonControllerTest do
test "Get /person/info returns person email when request header authorization is correct" do
assert {:ok, %Person{} = person} = AuthMvp.People.create_person(%{email: "[email protected]"})
jwt = AuthMvp.Token.generate_and_sign!(%{email: "[email protected]"})
conn = build_conn()
|> put_req_header("authorization", "Bearer #{jwt}")
|> get("/person/info")

assert json_response(conn, 200) == %{"data" => %{"email" => "[email protected]"}}
conn =
build_conn()
|> put_req_header("authorization", "Bearer #{jwt}")
|> get("/person/info")

response = json_response(conn, 200)
assert response["data"]["email"] == "[email protected]"
end
end

0 comments on commit 48c5450

Please sign in to comment.