Skip to content

Commit

Permalink
Merge pull request #66 from dwyl/use-auth_plug-issue-65
Browse files Browse the repository at this point in the history
PR: Use auth_plug to simplify auth in MPV App issue #65
  • Loading branch information
iteles authored Oct 4, 2020
2 parents 12347e6 + 2b5df63 commit 9d137bb
Show file tree
Hide file tree
Showing 31 changed files with 316 additions and 1,012 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ env:
before_script:
- mix do ecto.create, ecto.migrate
script:
- mix test
- mix coveralls.json
after_success:
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<div align="center">

# @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.

<div align="center">
<a href="https://agilevelocity.com/product-owner/mvp-mmf-psi-wtf-part-one-understanding-the-mvp">
<img src="https://user-images.githubusercontent.com/194400/65666966-b28dbd00-e036-11e9-9d11-1f5d3e22258e.png" width="500" alt="MVP Loop">
</a>
Expand All @@ -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
Expand All @@ -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. <br />
We have found it _tedious_ to use two _separate_ apps
for task and time tracking
Expand Down
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions coveralls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"skip_files": [
"test/",
"lib/app/application.ex",
"lib/app_web.ex",
"lib/app_web/views/error_helpers.ex"
]
}
5 changes: 2 additions & 3 deletions lib/app/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
163 changes: 18 additions & 145 deletions lib/app/ctx.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 """
Expand Down Expand Up @@ -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
Loading

0 comments on commit 9d137bb

Please sign in to comment.