Created
August 29, 2016 23:01
-
-
Save taylonr/040a91078d37f842fdc201bb6f2df68f to your computer and use it in GitHub Desktop.
Auth Controller
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 UeberTest.AuthController do | |
use UeberTest.Web, :controller | |
plug Ueberauth | |
alias Ueberauth.Strategy.Helpers | |
def request(conn, _params) do | |
render(conn, "request.html", callback_url: Helpers.callback_url(conn)) | |
end | |
def callback(%{assigns: %{ueberauth_failure: _fails}} = conn, _params) do | |
conn | |
|> put_flash(:error, "Failed to authenticate.") | |
|> redirect(to: "/") | |
end | |
def callback(%{assigns: %{ueberauth_auth: auth}} = conn, _params) do | |
conn | |
|> put_flash(:success, "Success") | |
|> redirect(to: "/") | |
# case UserFromAuth.find_or_create(auth) do | |
# {:ok, user} -> | |
# conn | |
# |> put_flash(:info, "Successfully authenticated.") | |
# |> put_session(:current_user, user) | |
# |> redirect(to: "/") | |
# {:error, reason} -> | |
# conn | |
# |> put_flash(:error, reason) | |
# |> redirect(to: "/") | |
# end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment