Skip to content

Instantly share code, notes, and snippets.

@javierg
Created December 22, 2016 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javierg/e1a13bca18d4c0cfc80d6f2a2fd8e4c1 to your computer and use it in GitHub Desktop.
Save javierg/e1a13bca18d4c0cfc80d6f2a2fd8e4c1 to your computer and use it in GitHub Desktop.
defmodule PhoenixUeberauthComeonin.PageController do
use PhoenixUeberauthComeonin.Web, :controller
plug Guardian.Plug.EnsureAuthenticated, handler: __MODULE__
def index(conn, _params) do
render conn, "index.html"
end
def unauthenticated(conn, _params) do
conn
|> put_status(401)
|> put_flash(:error, "Authentication required")
|> redirect(to: "/sessions/new")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment