Skip to content

Instantly share code, notes, and snippets.

@juanpabloaj
Created December 10, 2017 23:05
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 juanpabloaj/2bd3ca80bdf1b75cf33bdc92a90a3359 to your computer and use it in GitHub Desktop.
Save juanpabloaj/2bd3ca80bdf1b75cf33bdc92a90a3359 to your computer and use it in GitHub Desktop.
Add :coherence to your applications list in mix.exs.
def application do
[mod: {Chatourius, []},
applications: [..., :coherence]]
end
Add the following to your router.ex file.
defmodule Chatourius.Router do
use Chatourius.Web, :router
use Coherence.Router # Add this
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
plug Coherence.Authentication.Session # Add this
end
pipeline :protected do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
plug Coherence.Authentication.Session, protected: true # Add this
end
# Add this block
scope "/" do
pipe_through :browser
coherence_routes()
end
# Add this block
scope "/" do
pipe_through :protected
coherence_routes :protected
end
scope "/", Chatourius do
pipe_through :browser
get "/", PageController, :index
# Add public routes below
end
scope "/", Chatourius do
pipe_through :protected
# Add protected routes below
end
end
You might want to add the following to your priv/repo/seeds.exs file.
Chatourius.Repo.delete_all Chatourius.User
Chatourius.User.changeset(%Chatourius.User{}, %{name: "Test User", email: "testuser@example.com", pas
sword: "secret", password_confirmation: "secret"})
|> Chatourius.Repo.insert!
Don't forget to run the new migrations and seeds with:
$ mix ecto.setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment