This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def application do | |
[mod: {PhoenixUeberauthComeonin, []}, | |
applications: [ | |
... | |
:guardian, | |
:ueberauth, | |
:ueberauth_identity, | |
] | |
] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defp deps do | |
[ | |
... | |
{:guardian, "~> 0.13.0"} | |
] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias PhoenixUeberauthComeonin.Repo | |
Repo.insert! %User{ | |
name: "Administrator", | |
email: "[email protected]", | |
password: Comeonin.Bcrypt.hashpwsalt("admin") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule User do | |
use PhoenixUeberauthComeonin.Web, :model | |
import Comeonin.Bcrypt | |
alias Ueberauth.Auth | |
alias PhoenixUeberauthComeonin.Repo | |
schema "users" do | |
field :name, :string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_tag @callback_url, method: "post", class: "login", novalidate: true do %> | |
<div class="control-group"> | |
<label class="control-label" for="email-input">Email</label> | |
<input class="form-control" type="email" name="email" value="<%= @conn.params["email"] %>" required /> | |
</div> | |
<div class="control-group"> | |
<label class="control-label" for="password-input">Password</label> | |
<input class="form-control" type="password" name="password" required /> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule PhoenixUeberauthComeonin.SessionsView do | |
use PhoenixUeberauthComeonin.Web, :view | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule PhoenixUeberauthComeonin.SessionsController do | |
use PhoenixUeberauthComeonin.Web, :controller | |
alias Ueberauth.Strategy.Helpers | |
plug Ueberauth | |
def new(conn, _params) do | |
render conn, "new.html", callback_url: Helpers.callback_url(conn) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scope "/sessions", PhoenixUeberauthComeonin do | |
pipe_through [:browser] | |
get "/new", SessionsController, :new | |
post "/identity/callback", SessionsController, | |
:identity_callback | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config :ueberauth, Ueberauth, | |
providers: [ | |
identity: { Ueberauth.Strategy.Identity, [ | |
callback_methods: ["POST"], | |
uid_field: :email, | |
nickname_field: :email, | |
request_path: "/sessions/new", | |
callback_path: "/sessions/identity/callback", | |
]} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def application do | |
[mod: {PhoenixUeberauthComeonin, []}, | |
applications: [ | |
... | |
ueberauth, | |
ueberauth_identity, | |
... |