+
# @dwyl App MVP `Phoenix` ๐กโณ โ
-[![Build Status](https://travis-ci.com/dwyl/app-mvp-phoenix.svg?branch=master)](https://travis-ci.com/dwyl/app-mvp-phoenix)
-[![codecov](https://codecov.io/gh/dwyl/app-mvp-phoenix/branch/master/graph/badge.svg)](https://codecov.io/gh/dwyl/app-mvp-phoenix)
+A Phoenix`implementation
+of the @dwyl App [MVP feature set](https://github.com/dwyl/app/issues/266).
+
+[![Build Status](https://img.shields.io/travis/com/dwyl/app-mvp-phoenix/master?color=bright-green&style=flat-square)](https://travis-ci.org/dwyl/app-mvp-phoenix)
+[![codecov.io](https://img.shields.io/codecov/c/github/dwyl/app-mvp-phoenix/master.svg?style=flat-square)](http://codecov.io/github/dwyl/app-mvp-phoenix?branch=master)
+[![Hex.pm](https://img.shields.io/hexpm/v/elixir_auth_google?color=brightgreen&style=flat-square)](https://hex.pm/packages/elixir_auth_google)
+[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat-square)](https://github.com/dwyl/app-mvp-phoenix/issues)
+[![HitCount](http://hits.dwyl.io/dwyl/app-mvp-phoenix.svg)](http://hits.dwyl.io/dwyl/app-mvp-phoenix)
-A `Elixir`/`Phoenix` implementation
-of the @dwyl App MVP feature set.
-
@@ -17,9 +22,9 @@ of the @dwyl App MVP feature set.
Our objective with this MVP
is to build the minimal _useable_ App
-that covers our basic "Capture, Categorise, Complete"
+that covers our basic "Capture, Categorize, Complete"
[workflow](https://github.com/dwyl/product-roadmap#what)
-is well-documented, tested
+and is well-documented, tested
and easy for a _beginner_ to run/understand.
The goal is to _ship_ this App to
@@ -41,7 +46,7 @@ wanting the most _basic_ version of the app to _learn_.
# _What_? ๐ญ
A _hybrid_ note taking,
-information categorisation,
+information categorization,
task and activity (time) tracking tool.
We have found it _tedious_ to use two _separate_ apps
for task and time tracking
diff --git a/config/config.exs b/config/config.exs
index 1994e0ff..01479713 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -15,7 +15,7 @@ config :app, AppWeb.Endpoint,
url: [host: "localhost"],
secret_key_base: System.get_env("SECRET_KEY_BASE"),
render_errors: [view: AppWeb.ErrorView, accepts: ~w(html json)],
- pubsub: [name: App.PubSub, adapter: Phoenix.PubSub.PG2]
+ pubsub_server: App.PubSub
# Configures Elixir's Logger
config :logger, :console,
diff --git a/coveralls.json b/coveralls.json
new file mode 100644
index 00000000..5a0eef6f
--- /dev/null
+++ b/coveralls.json
@@ -0,0 +1,8 @@
+{
+ "skip_files": [
+ "test/",
+ "lib/app/application.ex",
+ "lib/app_web.ex",
+ "lib/app_web/views/error_helpers.ex"
+ ]
+}
diff --git a/lib/app/application.ex b/lib/app/application.ex
index 04f8a685..02015afa 100644
--- a/lib/app/application.ex
+++ b/lib/app/application.ex
@@ -11,9 +11,8 @@ defmodule App.Application do
# Start the Ecto repository
App.Repo,
# Start the endpoint when the application starts
- AppWeb.Endpoint
- # Starts a worker by calling: App.Worker.start_link(arg)
- # {App.Worker, arg},
+ AppWeb.Endpoint,
+ {Phoenix.PubSub, [name: App.PubSub, adapter: Phoenix.PubSub.PG2]}
]
# See https://hexdocs.pm/elixir/Supervisor.html
diff --git a/lib/app/ctx.ex b/lib/app/ctx.ex
index f0951c7c..772562bf 100644
--- a/lib/app/ctx.ex
+++ b/lib/app/ctx.ex
@@ -185,9 +185,9 @@ defmodule App.Ctx do
Repo.delete(status)
end
- def get_status_verified() do
- Repo.get_by(Status, text: "verified")
- end
+ # def get_status_verified() do
+ # Repo.get_by(Status, text: "verified")
+ # end
@doc """
Returns an `%Ecto.Changeset{}` for tracking status changes.
@@ -202,133 +202,6 @@ defmodule App.Ctx do
Status.changeset(status, %{})
end
- alias App.Ctx.Person
-
- @doc """
- Returns the list of people.
-
- ## Examples
-
- iex> list_people()
- [%Person{}, ...]
-
- """
- def list_people do
- Repo.all(Person)
- end
-
- @doc """
- Gets a single person.
-
- Raises `Ecto.NoResultsError` if the Person does not exist.
-
- ## Examples
-
- iex> get_person!(123)
- %Person{}
-
- iex> get_person!(456)
- ** (Ecto.NoResultsError)
-
- """
- def get_person!(id), do: Repo.get!(Person, id)
-
- @doc """
- Gets a single person.
- Returs `%Person{...}` or `nil` if not found
- """
- def get_person(id), do: Repo.get(Person, id)
-
- @doc """
- Get a person by email
- """
- def get_person_by_email(email) do
- Repo.get_by(Person, email_hash: email)
- end
-
- @doc """
- Creates a person.
-
- ## Examples
-
- iex> create_person(%{field: value})
- {:ok, %Person{}}
-
- iex> create_person(%{field: bad_value})
- {:error, %Ecto.Changeset{}}
-
- """
- def create_person(attrs \\ %{}) do
- %Person{}
- |> Person.changeset(attrs)
- |> Repo.insert()
- end
-
- @doc """
- Create a person from Google profile
- """
- def create_google_person(attrs \\ %{}) do
- %Person{}
- |> Person.google_changeset(attrs)
- |> Repo.insert()
- end
-
- @doc """
- Register a person with email/password
- """
- def register_person(attrs \\ %{}) do
- %Person{}
- |> Person.changeset_registration(attrs)
- |> Repo.insert()
- end
-
- @doc """
- Updates a person.
-
- ## Examples
-
- iex> update_person(person, %{field: new_value})
- {:ok, %Person{}}
-
- iex> update_person(person, %{field: bad_value})
- {:error, %Ecto.Changeset{}}
-
- """
- def update_person(%Person{} = person, attrs) do
- person
- |> Person.changeset(attrs)
- |> Repo.update()
- end
-
- @doc """
- Deletes a Person.
-
- ## Examples
-
- iex> delete_person(person)
- {:ok, %Person{}}
-
- iex> delete_person(person)
- {:error, %Ecto.Changeset{}}
-
- """
- def delete_person(%Person{} = person) do
- Repo.delete(person)
- end
-
- @doc """
- Returns an `%Ecto.Changeset{}` for tracking person changes.
-
- ## Examples
-
- iex> change_person(person)
- %Ecto.Changeset{source: %Person{}}
-
- """
- def change_person(%Person{} = person) do
- Person.changeset(person, %{})
- end
-
alias App.Ctx.Item
@doc """
@@ -617,21 +490,21 @@ defmodule App.Ctx do
Timer.changeset(timer, %{})
end
- alias App.Ctx.Session
+ # alias App.Ctx.Session
- @doc """
- Create a session
- """
- def create_session(user, attrs \\ %{}) do
- Session.changeset(user, attrs)
- |> Repo.insert()
- end
+ # @doc """
+ # Create a session
+ # """
+ # def create_session(user, attrs \\ %{}) do
+ # Session.changeset(user, attrs)
+ # |> Repo.insert()
+ # end
- @doc """
- Create a basic session
- """
- def create_basic_session(user, attrs \\ %{}) do
- Session.basic_changeset(user, attrs)
- |> Repo.insert()
- end
+ # @doc """
+ # Create a basic session
+ # """
+ # def create_basic_session(user, attrs \\ %{}) do
+ # Session.basic_changeset(user, attrs)
+ # |> Repo.insert()
+ # end
end
diff --git a/lib/app/ctx/person.ex b/lib/app/ctx/person.ex
deleted file mode 100644
index 55296edc..00000000
--- a/lib/app/ctx/person.ex
+++ /dev/null
@@ -1,146 +0,0 @@
-defmodule App.Ctx.Person do
- use Ecto.Schema
- import Ecto.Changeset
-
- schema "people" do
- field :email, Fields.EmailEncrypted
- field :email_hash, Fields.EmailHash
- field :familyName, Fields.Encrypted
- field :givenName, Fields.Encrypted
- field :locale, :string
- field :password, :string, virtual: true
- field :password_hash, Fields.Password
- field :picture, :binary
- field :username, :binary
- field :username_hash, Fields.Hash
- field :status, :id
- field :tag, :id
- field :key_id, :integer
-
- has_many :sessions, App.Ctx.Session, on_delete: :delete_all
- timestamps()
- end
-
- @doc """
- Default attributes validation for Person
- """
- def changeset(person, attrs) do
- person
- |> cast(attrs, [
- :username,
- :email,
- :givenName,
- :familyName,
- :password_hash,
- :key_id,
- :locale,
- :picture
- ])
- |> validate_required([
- :username,
- :email,
- :givenName,
- :familyName,
- :password_hash,
- :key_id
- ])
- |> put_email_hash()
- end
-
- @doc """
- Changeset used for Google OAuth authentication
- Add email hash and set status verified
- """
- def google_changeset(profile, attrs) do
- profile
- |> cast(attrs, [:email, :givenName, :familyName, :picture, :locale])
- |> validate_required([:email])
- |> put_email_hash()
- |> put_email_status_verified()
- end
-
- defp put_email_hash(changeset) do
- case changeset do
- %{valid?: true, changes: %{email: email}} ->
- put_change(changeset, :email_hash, email)
-
- _ ->
- changeset
- end
- end
-
- defp put_email_status_verified(changeset) do
- status_verified = App.Ctx.get_status_verified()
-
- case changeset do
- %{valid?: true} ->
- put_change(changeset, :status, status_verified.id)
-
- _ ->
- changeset
- end
- end
-
- @doc """
- `transform_profile_data_to_person/1` transforms the profile data
- received from invoking `ElixirAuthGoogle.get_user_profile/1`
- into a `person` record that can be inserted into the people table.
-
- ## Example
-
- iex> transform_profile_data_to_person(%{
- "email" => "nelson@gmail.com",
- "email_verified" => true,
- "family_name" => "Correia",
- "given_name" => "Nelson",
- "locale" => "en",
- "name" => "Nelson Correia",
- "picture" => "https://lh3.googleusercontent.com/a-/AAuE7mApnYb260YC1JY7a",
- "sub" => "940732358705212133793"
- })
- %{
- "email" => "nelson@gmail.com",
- "email_verified" => true,
- "family_name" => "Correia",
- "given_name" => "Nelson",
- "locale" => "en",
- "name" => "Nelson Correia",
- "picture" => "https://lh3.googleusercontent.com/a-/AAuE7mApnYb260YC1JY7a",
- "sub" => "940732358705212133793"
- "status" => 1,
- "familyName" => "Correia",
- "givenName" => "Nelson"
- }
- """
- def transform_profile_data_to_person(profile) do
- profile
- |> Map.put(:familyName, profile.family_name)
- |> Map.put(:givenName, profile.given_name)
- |> Map.put(:locale, profile.locale)
- |> Map.put(:picture, profile.picture)
- end
-
- @doc """
- Changeset function used for email/password registration
- Define email hash and password hash
- """
- def changeset_registration(profile, attrs) do
- profile
- |> cast(attrs, [:email, :password])
- |> validate_required([:email, :password])
- |> validate_length(:password, min: 6, max: 100)
- |> unique_constraint(:email)
- |> put_email_hash()
- |> put_pass_hash()
- end
-
- defp put_pass_hash(changeset) do
- case changeset do
- %Ecto.Changeset{valid?: true, changes: %{password: pass}} ->
- put_change(changeset, :password_hash, pass)
-
- _ ->
- changeset
- end
- end
-end
diff --git a/lib/app/ctx/session.ex b/lib/app/ctx/session.ex
index 6a4fc45d..1c80e518 100644
--- a/lib/app/ctx/session.ex
+++ b/lib/app/ctx/session.ex
@@ -1,23 +1,23 @@
-defmodule App.Ctx.Session do
- use Ecto.Schema
- import Ecto.Changeset
+# defmodule App.Ctx.Session do
+# use Ecto.Schema
+# import Ecto.Changeset
- schema "sessions" do
- field :auth_token, Fields.Encrypted
- field :refresh_token, Fields.Encrypted
- field :key_id, :integer
+# schema "sessions" do
+# field :auth_token, Fields.Encrypted
+# field :refresh_token, Fields.Encrypted
+# field :key_id, :integer
- belongs_to :person, App.Ctx.Person
- timestamps()
- end
+# belongs_to :person, App.Ctx.Person
+# timestamps()
+# end
- def changeset(people, attrs) do
- Ecto.build_assoc(people, :sessions)
- |> cast(attrs, [:auth_token, :refresh_token])
- |> validate_required([:auth_token, :refresh_token])
- end
+# def changeset(people, attrs) do
+# Ecto.build_assoc(people, :sessions)
+# |> cast(attrs, [:auth_token, :refresh_token])
+# |> validate_required([:auth_token, :refresh_token])
+# end
- def basic_changeset(people, _attrs) do
- Ecto.build_assoc(people, :sessions)
- end
-end
+# def basic_changeset(people, _attrs) do
+# Ecto.build_assoc(people, :sessions)
+# end
+# end
diff --git a/lib/app/person.ex b/lib/app/person.ex
new file mode 100644
index 00000000..25a32035
--- /dev/null
+++ b/lib/app/person.ex
@@ -0,0 +1,45 @@
+defmodule App.Person do
+ use Ecto.Schema
+ import Ecto.Changeset
+ alias App.Repo
+ # https://stackoverflow.com/a/47501059/1148249
+ alias __MODULE__
+
+ schema "people" do
+ field :status, :id
+ field :tag, :id
+ timestamps()
+ end
+
+ @doc """
+ Default attributes validation for Person
+ """
+ def changeset(person, attrs) do
+ person
+ |> cast(attrs, [:id, :status, :tag])
+ end
+
+ def create_person(attrs) do
+ changeset(%Person{}, attrs)
+ |> Repo.insert!()
+ end
+
+ def get_person(id) do
+ Repo.get_by(__MODULE__, id: id)
+ end
+
+ def upsert_person(person) do
+ case get_person(person.id) do
+ # not found:
+ nil ->
+ create_person(person)
+
+ # existing person:
+ ep ->
+ merged = Map.merge(AuthPlug.Helpers.strip_struct_metadata(ep), person)
+ {:ok, person} = Repo.update(changeset(%Person{id: ep.id}, merged))
+
+ person
+ end
+ end
+end
diff --git a/lib/app_web/controllers/auth_controller.ex b/lib/app_web/controllers/auth_controller.ex
index 0c9ba498..f19d153b 100644
--- a/lib/app_web/controllers/auth_controller.ex
+++ b/lib/app_web/controllers/auth_controller.ex
@@ -1,45 +1,9 @@
defmodule AppWeb.Auth do
use AppWeb, :controller
# use AppWeb, :router
- import Plug.Conn
- # alias App.Repo
+ # import Plug.Conn
- def init(opts), do: opts
-
- def call(conn, _opts) do
- person_id = get_session(conn, :person_id)
-
- cond do
- person = conn.assigns[:current_person] ->
- assign(conn, :current_person, person)
-
- person = person_id && App.Ctx.get_person(person_id) ->
- assign(conn, :current_person, person)
-
- true ->
- assign(conn, :current_person, nil)
- end
- end
-
- def login(conn, person) do
- conn
- |> assign(:current_person, person)
- |> put_session(:person_id, person.id)
- |> configure_session(renew: true)
- end
-
- def logout(conn) do
- configure_session(conn, drop: true)
- end
-
- def authenticate_person(conn, _opts) do
- if conn.assigns.current_person do
- conn
- else
- conn
- # redirect to login page
- |> redirect(to: Routes.page_path(conn, :index))
- |> halt()
- end
- end
+ # def logout(conn) do
+ # configure_session(conn, drop: true)
+ # end
end
diff --git a/lib/app_web/controllers/captures_controller.ex b/lib/app_web/controllers/captures_controller.ex
index 10425c4b..22a3f937 100644
--- a/lib/app_web/controllers/captures_controller.ex
+++ b/lib/app_web/controllers/captures_controller.ex
@@ -21,16 +21,16 @@ defmodule AppWeb.CaptureController do
end
end
- def api_create(conn, %{"text" => capture}) do
- case Ctx.create_item(%{text: capture}) do
- {:ok, item} ->
- render(conn, "capture.json", item: %{text: item.text})
+ # def api_create(conn, %{"text" => capture}) do
+ # case Ctx.create_item(%{text: capture}) do
+ # {:ok, item} ->
+ # render(conn, "capture.json", item: %{text: item.text})
- {:error, _} ->
- error = %{error: "The capture cannot be saved."}
- render(conn, "capture_error.json", err: error)
- end
- end
+ # {:error, _} ->
+ # error = %{error: "The capture cannot be saved."}
+ # render(conn, "capture_error.json", err: error)
+ # end
+ # end
def api_create(conn, _params) do
error = %{error: "text field is not defined"}
diff --git a/lib/app_web/controllers/google_auth_controller.ex b/lib/app_web/controllers/google_auth_controller.ex
deleted file mode 100644
index 6fb91d61..00000000
--- a/lib/app_web/controllers/google_auth_controller.ex
+++ /dev/null
@@ -1,42 +0,0 @@
-defmodule AppWeb.GoogleAuthController do
- use AppWeb, :controller
-
- @elixir_auth_google Application.get_env(:app, :elixir_auth_google) ||
- ElixirAuthGoogle
-
- def index(conn, %{"code" => code}) do
- {:ok, token} = @elixir_auth_google.get_token(code, conn)
- {:ok, profile} = @elixir_auth_google.get_user_profile(token.access_token)
- person = App.Ctx.Person.transform_profile_data_to_person(profile)
-
- # get the person by email
- case App.Ctx.get_person_by_email(person.email) do
- nil ->
- # Create the person
- {:ok, person} = App.Ctx.create_google_person(person)
- create_session(conn, person, token)
-
- person ->
- create_session(conn, person, token)
- end
- end
-
- def create_session(conn, person, token) do
- # Create session
- session_attrs = %{
- "auth_token" => token.access_token,
- "refresh_token" =>
- if Map.has_key?(token, :refresh_token) do
- token.refresh_token
- else
- nil
- end
- }
-
- App.Ctx.create_session(person, session_attrs)
-
- # login and redirect to welcome page:
- AppWeb.Auth.login(conn, person)
- |> redirect(to: Routes.person_path(conn, :info))
- end
-end
diff --git a/lib/app_web/controllers/page_controller.ex b/lib/app_web/controllers/page_controller.ex
index 6f5e3182..7a7beab9 100644
--- a/lib/app_web/controllers/page_controller.ex
+++ b/lib/app_web/controllers/page_controller.ex
@@ -1,65 +1,10 @@
defmodule AppWeb.PageController do
use AppWeb, :controller
- alias App.Ctx.Person
- alias App.Ctx
-
- # auth_controller assign current_person on each request
- # when the person is loggedin, otherwise the value doesn't exists or is nil
- def index(%{assigns: %{current_person: person}} = conn, _params)
- when not is_nil(person) do
- redirect(conn, to: Routes.person_path(conn, :info))
- end
+ alias App.Person
def index(conn, _params) do
- url_oauth_google = ElixirAuthGoogle.generate_oauth_url(conn)
- changeset = Person.changeset_registration(%Person{}, %{})
-
- render(conn, "index.html",
- url_oauth_google: url_oauth_google,
- changeset: changeset
- )
- end
-
- def register(conn, %{"person" => person_params}) do
- person = Ctx.get_person_by_email(person_params["email"])
-
- # create new person
- # Login person if password ok
- if is_nil(person) do
- case Ctx.register_person(person_params) do
- {:ok, person} ->
- create_basic_session(conn, person)
-
- {:error, %Ecto.Changeset{} = changeset} ->
- url_oauth_google = ElixirAuthGoogle.generate_oauth_url(conn)
-
- render(conn, "index.html",
- url_oauth_google: url_oauth_google,
- changeset: changeset
- )
- end
- else
- login(conn, person, person_params)
- end
- end
-
- # verify provided password
- # create Phx session
- # and redirect to correct page:
- # user info page if password ok or index page if it doesn't match
- defp login(conn, person, person_params) do
- if Argon2.verify_pass(person_params["password"], person.password_hash) do
- create_basic_session(conn, person)
- else
- redirect(conn, to: Routes.page_path(conn, :index))
- end
- end
-
- # Insert a new basic session in Postgres
- defp create_basic_session(conn, person) do
- App.Ctx.create_basic_session(person, %{})
+ changeset = Person.changeset(%Person{}, %{})
- AppWeb.Auth.login(conn, person)
- |> redirect(to: Routes.person_path(conn, :info))
+ render(conn, "index.html", changeset: changeset)
end
end
diff --git a/lib/app_web/controllers/person_controller.ex b/lib/app_web/controllers/person_controller.ex
deleted file mode 100644
index 4fa759cb..00000000
--- a/lib/app_web/controllers/person_controller.ex
+++ /dev/null
@@ -1,72 +0,0 @@
-defmodule AppWeb.PersonController do
- use AppWeb, :controller
-
- alias App.Ctx
- alias App.Ctx.Person
-
- def index(conn, _params) do
- people = Ctx.list_people()
- render(conn, "index.html", people: people)
- end
-
- def new(conn, _params) do
- changeset = Ctx.change_person(%Person{})
- render(conn, "new.html", changeset: changeset)
- end
-
- def create(conn, %{"person" => person_params}) do
- case Ctx.create_person(person_params) do
- {:ok, person} ->
- conn
- |> put_flash(:info, "Person created successfully.")
- |> redirect(to: Routes.person_path(conn, :show, person))
-
- {:error, %Ecto.Changeset{} = changeset} ->
- render(conn, "new.html", changeset: changeset)
- end
- end
-
- def show(conn, %{"id" => id}) do
- person = Ctx.get_person!(id)
- render(conn, "show.html", person: person)
- end
-
- def edit(conn, %{"id" => id}) do
- person = Ctx.get_person!(id)
- changeset = Ctx.change_person(person)
- render(conn, "edit.html", person: person, changeset: changeset)
- end
-
- def update(conn, %{"id" => id, "person" => person_params}) do
- person = Ctx.get_person!(id)
-
- case Ctx.update_person(person, person_params) do
- {:ok, person} ->
- conn
- |> put_flash(:info, "Person updated successfully.")
- |> redirect(to: Routes.person_path(conn, :show, person))
-
- {:error, %Ecto.Changeset{} = changeset} ->
- render(conn, "edit.html", person: person, changeset: changeset)
- end
- end
-
- def delete(conn, %{"id" => id}) do
- person = Ctx.get_person!(id)
- {:ok, _person} = Ctx.delete_person(person)
-
- conn
- |> put_flash(:info, "Person deleted successfully.")
- |> redirect(to: Routes.person_path(conn, :index))
- end
-
- def info(%{assigns: %{current_person: person}} = conn, _params) do
- render(conn, "info.html", person: person)
- end
-
- def logout(conn, _params) do
- conn
- |> AppWeb.Auth.logout()
- |> redirect(to: Routes.page_path(conn, :index))
- end
-end
diff --git a/lib/app_web/controllers/sessions_controller.ex b/lib/app_web/controllers/sessions_controller.ex
index a13631cf..9315efdc 100644
--- a/lib/app_web/controllers/sessions_controller.ex
+++ b/lib/app_web/controllers/sessions_controller.ex
@@ -1,9 +1,9 @@
defmodule AppWeb.SessionController do
use AppWeb, :controller
- def delete(conn, _params) do
- conn
- |> AppWeb.Auth.logout()
- |> redirect(to: Routes.page_path(conn, :index))
- end
+ # def delete(conn, _params) do
+ # conn
+ # |> AppWeb.Auth.logout()
+ # |> redirect(to: Routes.page_path(conn, :index))
+ # end
end
diff --git a/lib/app_web/router.ex b/lib/app_web/router.ex
index 1758f60c..aa7a8a83 100644
--- a/lib/app_web/router.ex
+++ b/lib/app_web/router.ex
@@ -1,6 +1,6 @@
defmodule AppWeb.Router do
use AppWeb, :router
- import AppWeb.Auth
+ # import AppWeb.Auth
pipeline :browser do
plug :accepts, ["html"]
@@ -8,7 +8,7 @@ defmodule AppWeb.Router do
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
- plug AppWeb.Auth
+ # plug AppWeb.Auth
end
pipeline :api do
@@ -21,24 +21,23 @@ defmodule AppWeb.Router do
plug :accepts, ["json"]
end
- pipeline :person do
- plug :authenticate_person
- end
+ pipeline :auth_optional, do: plug(AuthPlugOptional, %{})
scope "/", AppWeb do
- pipe_through :browser
+ pipe_through [:browser, :auth_optional]
get "/", PageController, :index
- post "/register", PageController, :register
- get "/auth/google/callback", GoogleAuthController, :index
+ # post "/register", PageController, :index
end
+ pipeline :auth,
+ do: plug(AuthPlug, %{auth_url: "https://dwylauth.herokuapp.com"})
+
scope "/", AppWeb do
- pipe_through [:browser, :person]
+ pipe_through [:browser, :auth]
- # person information
- get "/people/info", PersonController, :info
- get "/people/logout", PersonController, :logout
+ # need to re-create logout
+ # get "/people/logout", PersonController, :logout
# generic resources for schemas:
resources "/items", ItemController
@@ -60,8 +59,8 @@ defmodule AppWeb.Router do
pipe_through :api
post "/captures/create", CaptureController, :api_create
- options "/captures/create", CaptureController, :api_create
+ # options "/captures/create", CaptureController, :api_create
get "/items", ItemController, :api_index
- options "/items", ItemController, :api_index
+ # options "/items", ItemController, :api_index
end
end
diff --git a/lib/app_web/templates/layout/app.html.eex b/lib/app_web/templates/layout/app.html.eex
index 0516576c..a19d23c5 100644
--- a/lib/app_web/templates/layout/app.html.eex
+++ b/lib/app_web/templates/layout/app.html.eex
@@ -32,7 +32,7 @@
<%= get_flash(@conn, :info) %>
<%= get_flash(@conn, :error) %>
- <%= render @view_module, @view_template, assigns %>
+ <%= @inner_content %>