Skip to content

Commit

Permalink
add auth_plug to mix.exs for #42
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Apr 22, 2020
1 parent 0113b18 commit fd81e72
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
6 changes: 1 addition & 5 deletions lib/auth_web/controllers/auth_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ defmodule AuthWeb.AuthController do
`google_handler/2` handles the callback from Google Auth API redirect.
"""
def google_handler(conn, %{"code" => code, "state" => state}) do
IO.inspect(state, label: "state")
{:ok, token} = ElixirAuthGoogle.get_token(code, conn)
IO.inspect(token, label: "token")
{:ok, profile} = ElixirAuthGoogle.get_user_profile(token.access_token)
IO.inspect(profile, label: "profile")

# save profile to people:
person = Person.create_google_person(profile)
Expand All @@ -42,7 +39,7 @@ defmodule AuthWeb.AuthController do
if the state is defined, redirect to it.
"""
def handler(conn, person, state) do
IO.inspect(person, label: "handler/3 > person")
# IO.inspect(person, label: "handler/3 > person")
# Send welcome email:
Auth.Email.sendemail(%{
email: person.email,
Expand Down Expand Up @@ -75,7 +72,6 @@ defmodule AuthWeb.AuthController do
}

jwt = Auth.Token.generate_and_sign!(data)
# |> IO.inspect(label: "jwt")
URI.decode(state) <> "?jwt=" <> jwt
end
end
16 changes: 11 additions & 5 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,24 @@ defmodule Auth.Mixfile do
{:jason, "~> 1.2.0"},
{:plug_cowboy, "~> 2.1.3"},

# Field Validation and Encryption:
{:fields, "~> 2.4.0"},

# Auth:
# https://github.com/dwyl/elixir-auth-github
{:elixir_auth_github, "~> 1.2.0"},
# https://github.com/dwyl/elixir-auth-google
{:elixir_auth_google, "~> 1.2.0"},
# https://github.com/dwyl/auth_plug
{:auth_plug, "~> 0.4.0"},

# Field Validation and Encryption: github.com/dwyl/fields
{:fields, "~> 2.4.0"},

# Crete JSON Web Tokens
{:joken, "~> 2.2"},

# check test coverage
# Check test coverage
{:excoveralls, "~> 0.12.3", only: :test},

# For publishing Hex.docs:
# Create Documentation for publishing Hex.docs:
{:ex_doc, "~> 0.21.3", only: :dev}
]
end
Expand Down
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
%{
"argon2_elixir": {:hex, :argon2_elixir, "2.3.0", "e251bdafd69308e8c1263e111600e6d68bd44f23d2cccbe43fcb1a417a76bc8e", [:make, :mix], [{:comeonin, "~> 5.3", [hex: :comeonin, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "28ccb63bff213aecec1f7f3dde9648418b031f822499973281d8f494b9d5a3b3"},
"auth_plug": {:hex, :auth_plug, "0.4.0", "73c460b0dce833f864726502b79b962f5fa788c5c31af5cbc85fd38a38edb3f0", [:mix], [{:joken, "~> 2.2", [hex: :joken, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "79808c94e7f2e6af63222d17aff891528d3e24f7be75c5d1c4b0983c9054bd79"},
"certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "805abd97539caf89ec6d4732c91e62ba9da0cda51ac462380bbd28ee697a8c42"},
"comeonin": {:hex, :comeonin, "5.3.1", "7fe612b739c78c9c1a75186ef2d322ce4d25032d119823269d0aa1e2f1e20025", [:mix], [], "hexpm", "d6222483060c17f0977fad1b7401ef0c5863c985a64352755f366aee3799c245"},
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm", "4a0850c9be22a43af9920a71ab17c051f5f7d45c209e40269a1938832510e4d9"},
Expand Down

0 comments on commit fd81e72

Please sign in to comment.