diff --git a/apps/admin/mix.exs b/apps/admin/mix.exs index 3dd2f683..7bc29e75 100644 --- a/apps/admin/mix.exs +++ b/apps/admin/mix.exs @@ -39,7 +39,6 @@ defmodule Admin.MixProject do # Type `mix help deps` for examples and options. defp deps do [ - {:auth_web, in_umbrella: true}, {:core, in_umbrella: true}, {:ecto_sql, "~> 3.4"}, {:excoveralls, "~> 0.10", only: [:dev, :test]}, diff --git a/apps/app/lib/app_web/endpoint.ex b/apps/app/lib/app_web/endpoint.ex index 42f62e92..3af6dd5e 100644 --- a/apps/app/lib/app_web/endpoint.ex +++ b/apps/app/lib/app_web/endpoint.ex @@ -56,7 +56,7 @@ defmodule AppWeb.Endpoint do plug Plug.MethodOverride plug Plug.Head plug Plug.Session, @session_options - plug Pow.Plug.Session, otp_app: :auth_web + plug Pow.Plug.Session, otp_app: :core plug PowPersistentSession.Plug.Cookie plug AppWeb.Router end diff --git a/apps/auth/.formatter.exs b/apps/auth/.formatter.exs deleted file mode 100644 index db861480..00000000 --- a/apps/auth/.formatter.exs +++ /dev/null @@ -1,5 +0,0 @@ -[ - import_deps: [:ecto], - inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"], - subdirectories: ["priv/*/migrations"] -] diff --git a/apps/auth/.gitignore b/apps/auth/.gitignore deleted file mode 100644 index 9787d3f8..00000000 --- a/apps/auth/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -# The directory Mix will write compiled artifacts to. -/_build/ - -# If you run "mix test --cover", coverage assets end up here. -/cover/ - -# The directory Mix downloads your dependencies sources to. -/deps/ - -# Where 3rd-party dependencies like ExDoc output generated docs. -/doc/ - -# Ignore .fetch files in case you like to edit your project deps locally. -/.fetch - -# If the VM crashes, it generates a dump, let's ignore it too. -erl_crash.dump - -# Also ignore archive artifacts (built via "mix archive.build"). -*.ez - -# Ignore package tarball (built via "mix hex.build"). -auth-*.tar diff --git a/apps/auth/README.md b/apps/auth/README.md deleted file mode 100644 index 08e7f49a..00000000 --- a/apps/auth/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Auth - -**TODO: Add description** diff --git a/apps/auth/lib/auth/application.ex b/apps/auth/lib/auth/application.ex deleted file mode 100644 index fc75307a..00000000 --- a/apps/auth/lib/auth/application.ex +++ /dev/null @@ -1,20 +0,0 @@ -defmodule Auth.Application do - # See https://hexdocs.pm/elixir/Application.html - # for more information on OTP Applications - @moduledoc false - - use Application - - def start(_type, _args) do - children = [ - # Start the Ecto repository - Auth.Repo, - # Start the PubSub system - {Phoenix.PubSub, name: Auth.PubSub} - # Start a worker by calling: Auth.Worker.start_link(arg) - # {Auth.Worker, arg} - ] - - Supervisor.start_link(children, strategy: :one_for_one, name: Auth.Supervisor) - end -end diff --git a/apps/auth/lib/auth/repo.ex b/apps/auth/lib/auth/repo.ex deleted file mode 100644 index d2c26ac4..00000000 --- a/apps/auth/lib/auth/repo.ex +++ /dev/null @@ -1,5 +0,0 @@ -defmodule Auth.Repo do - use Ecto.Repo, - otp_app: :auth, - adapter: Ecto.Adapters.Postgres -end diff --git a/apps/auth/mix.exs b/apps/auth/mix.exs deleted file mode 100644 index 23394567..00000000 --- a/apps/auth/mix.exs +++ /dev/null @@ -1,63 +0,0 @@ -defmodule Auth.MixProject do - use Mix.Project - - def project do - [ - app: :auth, - version: "0.1.0", - build_path: "../../_build", - config_path: "../../config/config.exs", - deps_path: "../../deps", - lockfile: "../../mix.lock", - elixir: "~> 1.7", - elixirc_paths: elixirc_paths(Mix.env()), - start_permanent: Mix.env() == :prod, - aliases: aliases(), - deps: deps(), - test_coverage: [tool: ExCoveralls], - preferred_cli_env: [coveralls: :test, "coveralls.detail": :test, "coveralls.post": :test, "coveralls.html": :test], - ] - end - - # Configuration for the OTP application. - # - # Type `mix help compile.app` for more information. - def application do - [ - mod: {Auth.Application, []}, - extra_applications: [:logger, :runtime_tools] - ] - end - - # Specifies which paths to compile per environment. - defp elixirc_paths(:test), do: ["lib", "test/support"] - defp elixirc_paths(_), do: ["lib"] - - # Specifies your project dependencies. - # - # Type `mix help deps` for examples and options. - defp deps do - [ - {:ex_prompt, "~> 0.1.5"}, - {:excoveralls, "~> 0.10", only: [:dev, :test]}, - {:phoenix_pubsub, "~> 2.0"}, - {:pow, "~> 1.0.20"}, - {:ecto_sql, "~> 3.4"}, - {:postgrex, ">= 0.0.0"}, - {:jason, "~> 1.0"} - ] - end - - # Aliases are shortcuts or tasks specific to the current project. - # - # See the documentation for `Mix` for more info on aliases. - defp aliases do - [ - setup: ["deps.get", "ecto.setup"], - "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"], - "ecto.reset": ["ecto.drop", "ecto.setup"], - test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"], - "npm.install": [], - ] - end -end diff --git a/apps/auth/priv/repo/migrations/.formatter.exs b/apps/auth/priv/repo/migrations/.formatter.exs deleted file mode 100644 index 49f9151e..00000000 --- a/apps/auth/priv/repo/migrations/.formatter.exs +++ /dev/null @@ -1,4 +0,0 @@ -[ - import_deps: [:ecto_sql], - inputs: ["*.exs"] -] diff --git a/apps/auth/priv/repo/seeds.exs b/apps/auth/priv/repo/seeds.exs deleted file mode 100644 index e2497a21..00000000 --- a/apps/auth/priv/repo/seeds.exs +++ /dev/null @@ -1,11 +0,0 @@ -# Script for populating the database. You can run it as: -# -# mix run priv/repo/seeds.exs -# -# Inside the script, you can read and write to any of your -# repositories directly: -# -# Auth.Repo.insert!(%Auth.SomeSchema{}) -# -# We recommend using the bang functions (`insert!`, `update!` -# and so on) as they will fail if something goes wrong. diff --git a/apps/auth/test/support/data_case.ex b/apps/auth/test/support/data_case.ex deleted file mode 100644 index f4ac7359..00000000 --- a/apps/auth/test/support/data_case.ex +++ /dev/null @@ -1,55 +0,0 @@ -defmodule Auth.DataCase do - @moduledoc """ - This module defines the setup for tests requiring - access to the application's data layer. - - You may define functions here to be used as helpers in - your tests. - - Finally, if the test case interacts with the database, - we enable the SQL sandbox, so changes done to the database - are reverted at the end of every test. If you are using - PostgreSQL, you can even run database tests asynchronously - by setting `use Auth.DataCase, async: true`, although - this option is not recommended for other databases. - """ - - use ExUnit.CaseTemplate - - using do - quote do - alias Auth.Repo - - import Ecto - import Ecto.Changeset - import Ecto.Query - import Auth.DataCase - end - end - - setup tags do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(Auth.Repo) - - unless tags[:async] do - Ecto.Adapters.SQL.Sandbox.mode(Auth.Repo, {:shared, self()}) - end - - :ok - end - - @doc """ - A helper that transforms changeset errors into a map of messages. - - assert {:error, changeset} = Accounts.create_user(%{password: "short"}) - assert "password is too short" in errors_on(changeset).password - assert %{password: ["password is too short"]} = errors_on(changeset) - - """ - def errors_on(changeset) do - Ecto.Changeset.traverse_errors(changeset, fn {message, opts} -> - Regex.replace(~r"%{(\w+)}", message, fn _, key -> - opts |> Keyword.get(String.to_existing_atom(key), key) |> to_string() - end) - end) - end -end diff --git a/apps/auth/test/test_helper.exs b/apps/auth/test/test_helper.exs deleted file mode 100644 index 26689cc8..00000000 --- a/apps/auth/test/test_helper.exs +++ /dev/null @@ -1,2 +0,0 @@ -ExUnit.start() -Ecto.Adapters.SQL.Sandbox.mode(Auth.Repo, :manual) diff --git a/apps/auth_web/.formatter.exs b/apps/auth_web/.formatter.exs deleted file mode 100644 index 47616780..00000000 --- a/apps/auth_web/.formatter.exs +++ /dev/null @@ -1,4 +0,0 @@ -[ - import_deps: [:phoenix], - inputs: ["*.{ex,exs}", "{config,lib,test}/**/*.{ex,exs}"] -] diff --git a/apps/auth_web/.gitignore b/apps/auth_web/.gitignore deleted file mode 100644 index 2ebe6e95..00000000 --- a/apps/auth_web/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -# The directory Mix will write compiled artifacts to. -/_build/ - -# If you run "mix test --cover", coverage assets end up here. -/cover/ - -# The directory Mix downloads your dependencies sources to. -/deps/ - -# Where 3rd-party dependencies like ExDoc output generated docs. -/doc/ - -# Ignore .fetch files in case you like to edit your project deps locally. -/.fetch - -# If the VM crashes, it generates a dump, let's ignore it too. -erl_crash.dump - -# Also ignore archive artifacts (built via "mix archive.build"). -*.ez - -# Ignore package tarball (built via "mix hex.build"). -auth_web-*.tar - -# If NPM crashes, it generates a log, let's ignore it too. -npm-debug.log - -# The directory NPM downloads your dependencies sources to. -/assets/node_modules/ - -# Since we are building assets from assets/, -# we ignore priv/static. You may want to comment -# this depending on your deployment strategy. -/priv/static/ diff --git a/apps/auth_web/README.md b/apps/auth_web/README.md deleted file mode 100644 index 4b719e74..00000000 --- a/apps/auth_web/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# AuthWeb - -To start your Phoenix server: - - * Install dependencies with `mix deps.get` - * Create and migrate your database with `mix ecto.setup` - * Install Node.js dependencies with `npm install` inside the `assets` directory - * Start Phoenix endpoint with `mix phx.server` - -Now you can visit [`localhost:4000`](http://localhost:4000) from your browser. - -Ready to run in production? Please [check our deployment guides](https://hexdocs.pm/phoenix/deployment.html). - -## Learn more - - * Official website: https://www.phoenixframework.org/ - * Guides: https://hexdocs.pm/phoenix/overview.html - * Docs: https://hexdocs.pm/phoenix - * Forum: https://elixirforum.com/c/phoenix-forum - * Source: https://github.com/phoenixframework/phoenix diff --git a/apps/auth_web/lib/auth_web/application.ex b/apps/auth_web/lib/auth_web/application.ex deleted file mode 100644 index b76f9334..00000000 --- a/apps/auth_web/lib/auth_web/application.ex +++ /dev/null @@ -1,30 +0,0 @@ -defmodule AuthWeb.Application do - # See https://hexdocs.pm/elixir/Application.html - # for more information on OTP Applications - @moduledoc false - - use Application - - def start(_type, _args) do - children = [ - # Start the Telemetry supervisor - AuthWeb.Telemetry, - # Start the Endpoint (http/https) - AuthWeb.Endpoint - # Start a worker by calling: AuthWeb.Worker.start_link(arg) - # {AuthWeb.Worker, arg} - ] - - # See https://hexdocs.pm/elixir/Supervisor.html - # for other strategies and supported options - opts = [strategy: :one_for_one, name: AuthWeb.Supervisor] - Supervisor.start_link(children, opts) - end - - # Tell Phoenix to update the endpoint configuration - # whenever the application is updated. - def config_change(changed, _new, removed) do - AuthWeb.Endpoint.config_change(changed, removed) - :ok - end -end diff --git a/apps/auth_web/lib/auth_web/channels/user_socket.ex b/apps/auth_web/lib/auth_web/channels/user_socket.ex deleted file mode 100644 index 064501ad..00000000 --- a/apps/auth_web/lib/auth_web/channels/user_socket.ex +++ /dev/null @@ -1,35 +0,0 @@ -defmodule AuthWeb.UserSocket do - use Phoenix.Socket - - ## Channels - # channel "room:*", AuthWeb.RoomChannel - - # Socket params are passed from the client and can - # be used to verify and authenticate a user. After - # verification, you can put default assigns into - # the socket that will be set for all channels, ie - # - # {:ok, assign(socket, :user_id, verified_user_id)} - # - # To deny connection, return `:error`. - # - # See `Phoenix.Token` documentation for examples in - # performing token verification on connect. - @impl true - def connect(_params, socket, _connect_info) do - {:ok, socket} - end - - # Socket id's are topics that allow you to identify all sockets for a given user: - # - # def id(socket), do: "user_socket:#{socket.assigns.user_id}" - # - # Would allow you to broadcast a "disconnect" event and terminate - # all active sockets and channels for a given user: - # - # AuthWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{}) - # - # Returning `nil` makes this socket anonymous. - @impl true - def id(_socket), do: nil -end diff --git a/apps/auth_web/lib/auth_web/endpoint.ex b/apps/auth_web/lib/auth_web/endpoint.ex deleted file mode 100644 index 71c7661e..00000000 --- a/apps/auth_web/lib/auth_web/endpoint.ex +++ /dev/null @@ -1,54 +0,0 @@ -defmodule AuthWeb.Endpoint do - use Phoenix.Endpoint, otp_app: :auth_web - - # The session will be stored in the cookie and signed, - # this means its contents can be read but not tampered with. - # Set :encryption_salt if you would also like to encrypt it. - @session_options [ - store: :cookie, - key: "_auth_web_key", - signing_salt: "bwwz3vUK" - ] - - socket "/socket", AuthWeb.UserSocket, - websocket: true, - longpoll: false - - socket "/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]] - - # Serve at "/" the static files from "priv/static" directory. - # - # You should set gzip to true if you are running phx.digest - # when deploying your static files in production. - plug Plug.Static, - at: "/", - from: :auth_web, - gzip: false, - only: ~w(css fonts images js favicon.ico robots.txt) - - # Code reloading can be explicitly enabled under the - # :code_reloader configuration of your endpoint. - if code_reloading? do - socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket - plug Phoenix.LiveReloader - plug Phoenix.CodeReloader - plug Phoenix.Ecto.CheckRepoStatus, otp_app: :auth_web - end - - plug Phoenix.LiveDashboard.RequestLogger, - param_key: "request_logger", - cookie_key: "request_logger" - - plug Plug.RequestId - plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint] - - plug Plug.Parsers, - parsers: [:urlencoded, :multipart, :json], - pass: ["*/*"], - json_decoder: Phoenix.json_library() - - plug Plug.MethodOverride - plug Plug.Head - plug Plug.Session, @session_options - plug AuthWeb.Router -end diff --git a/apps/auth_web/lib/auth_web/gettext.ex b/apps/auth_web/lib/auth_web/gettext.ex deleted file mode 100644 index 75c81bc8..00000000 --- a/apps/auth_web/lib/auth_web/gettext.ex +++ /dev/null @@ -1,24 +0,0 @@ -defmodule AuthWeb.Gettext do - @moduledoc """ - A module providing Internationalization with a gettext-based API. - - By using [Gettext](https://hexdocs.pm/gettext), - your module gains a set of macros for translations, for example: - - import AuthWeb.Gettext - - # Simple translation - gettext("Here is the string to translate") - - # Plural translation - ngettext("Here is the string to translate", - "Here are the strings to translate", - 3) - - # Domain-based translation - dgettext("errors", "Here is the error message to translate") - - See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage. - """ - use Gettext, otp_app: :auth_web -end diff --git a/apps/auth_web/lib/auth_web/router.ex b/apps/auth_web/lib/auth_web/router.ex deleted file mode 100644 index f298d1d0..00000000 --- a/apps/auth_web/lib/auth_web/router.ex +++ /dev/null @@ -1,25 +0,0 @@ -defmodule AuthWeb.Router do - use AuthWeb, :router - use Pow.Phoenix.Router - use Pow.Extension.Phoenix.Router, - extensions: [PowResetPassword, PowEmailConfirmation] - - pipeline :browser do - plug :accepts, ["html"] - plug :fetch_session - plug :fetch_flash - plug :protect_from_forgery - plug :put_secure_browser_headers - end - - pipeline :api do - plug :accepts, ["json"] - end - - scope "/" do - pipe_through :browser - - pow_routes() - pow_extension_routes() - end -end diff --git a/apps/auth_web/lib/auth_web/telemetry.ex b/apps/auth_web/lib/auth_web/telemetry.ex deleted file mode 100644 index da2b55bc..00000000 --- a/apps/auth_web/lib/auth_web/telemetry.ex +++ /dev/null @@ -1,58 +0,0 @@ -defmodule AuthWeb.Telemetry do - @moduledoc """ - Telemetry configuration for AuthWeb app. - """ - use Supervisor - import Telemetry.Metrics - - def start_link(arg) do - Supervisor.start_link(__MODULE__, arg, name: __MODULE__) - end - - @impl true - def init(_arg) do - children = [ - # Telemetry poller will execute the given period measurements - # every 10_000ms. Learn more here: https://hexdocs.pm/telemetry_metrics - {:telemetry_poller, measurements: periodic_measurements(), period: 10_000} - # Add reporters as children of your supervision tree. - # {Telemetry.Metrics.ConsoleReporter, metrics: metrics()} - ] - - Supervisor.init(children, strategy: :one_for_one) - end - - def metrics do - [ - # Phoenix Metrics - summary("phoenix.endpoint.stop.duration", - unit: {:native, :millisecond} - ), - summary("phoenix.router_dispatch.stop.duration", - tags: [:route], - unit: {:native, :millisecond} - ), - - # Database Metrics - summary("auth_web.repo.query.total_time", unit: {:native, :millisecond}), - summary("auth_web.repo.query.decode_time", unit: {:native, :millisecond}), - summary("auth_web.repo.query.query_time", unit: {:native, :millisecond}), - summary("auth_web.repo.query.queue_time", unit: {:native, :millisecond}), - summary("auth_web.repo.query.idle_time", unit: {:native, :millisecond}), - - # VM Metrics - summary("vm.memory.total", unit: {:byte, :kilobyte}), - summary("vm.total_run_queue_lengths.total"), - summary("vm.total_run_queue_lengths.cpu"), - summary("vm.total_run_queue_lengths.io") - ] - end - - defp periodic_measurements do - [ - # A module, function and arguments to be invoked periodically. - # This function must call :telemetry.execute/3 and a metric must be added above. - # {AuthWeb, :count_users, []} - ] - end -end diff --git a/apps/auth_web/mix.exs b/apps/auth_web/mix.exs deleted file mode 100644 index 8dfa0f54..00000000 --- a/apps/auth_web/mix.exs +++ /dev/null @@ -1,70 +0,0 @@ -defmodule AuthWeb.MixProject do - use Mix.Project - - def project do - [ - app: :auth_web, - version: "0.1.0", - build_path: "../../_build", - config_path: "../../config/config.exs", - deps_path: "../../deps", - lockfile: "../../mix.lock", - elixir: "~> 1.7", - elixirc_paths: elixirc_paths(Mix.env()), - compilers: [:phoenix, :gettext] ++ Mix.compilers(), - start_permanent: Mix.env() == :prod, - aliases: aliases(), - deps: deps(), - test_coverage: [tool: ExCoveralls], - preferred_cli_env: [coveralls: :test, "coveralls.detail": :test, "coveralls.post": :test, "coveralls.html": :test], - ] - end - - # Configuration for the OTP application. - # - # Type `mix help compile.app` for more information. - def application do - [ - mod: {AuthWeb.Application, []}, - extra_applications: [:logger, :runtime_tools] - ] - end - - # Specifies which paths to compile per environment. - defp elixirc_paths(:test), do: ["lib", "test/support"] - defp elixirc_paths(_), do: ["lib"] - - # Specifies your project dependencies. - # - # Type `mix help deps` for examples and options. - defp deps do - [ - {:auth, in_umbrella: true}, - {:core, in_umbrella: true}, - {:excoveralls, "~> 0.10", only: [:dev, :test]}, - {:phoenix, "~> 1.5.3"}, - {:phoenix_ecto, "~> 4.0"}, - {:phoenix_html, "~> 2.11"}, - {:phoenix_live_reload, "~> 1.2", only: :dev}, - {:phoenix_live_dashboard, "~> 0.2.0"}, - {:pow, "~> 1.0.20"}, - {:telemetry_metrics, "~> 0.4"}, - {:telemetry_poller, "~> 0.4"}, - {:gettext, "~> 0.11"}, - {:jason, "~> 1.0"}, - {:plug_cowboy, "~> 2.0"} - ] - end - - # Aliases are shortcuts or tasks specific to the current project. - # - # See the documentation for `Mix` for more info on aliases. - defp aliases do - [ - setup: ["deps.get", "cmd npm install --prefix assets"], - test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"], - "ecto.migrate": [], - "npm.install": [], - ] - end -end diff --git a/apps/auth_web/priv/gettext/en/LC_MESSAGES/errors.po b/apps/auth_web/priv/gettext/en/LC_MESSAGES/errors.po deleted file mode 100644 index a589998c..00000000 --- a/apps/auth_web/priv/gettext/en/LC_MESSAGES/errors.po +++ /dev/null @@ -1,97 +0,0 @@ -## `msgid`s in this file come from POT (.pot) files. -## -## Do not add, change, or remove `msgid`s manually here as -## they're tied to the ones in the corresponding POT file -## (with the same domain). -## -## Use `mix gettext.extract --merge` or `mix gettext.merge` -## to merge POT files into PO files. -msgid "" -msgstr "" -"Language: en\n" - -## From Ecto.Changeset.cast/4 -msgid "can't be blank" -msgstr "" - -## From Ecto.Changeset.unique_constraint/3 -msgid "has already been taken" -msgstr "" - -## From Ecto.Changeset.put_change/3 -msgid "is invalid" -msgstr "" - -## From Ecto.Changeset.validate_acceptance/3 -msgid "must be accepted" -msgstr "" - -## From Ecto.Changeset.validate_format/3 -msgid "has invalid format" -msgstr "" - -## From Ecto.Changeset.validate_subset/3 -msgid "has an invalid entry" -msgstr "" - -## From Ecto.Changeset.validate_exclusion/3 -msgid "is reserved" -msgstr "" - -## From Ecto.Changeset.validate_confirmation/3 -msgid "does not match confirmation" -msgstr "" - -## From Ecto.Changeset.no_assoc_constraint/3 -msgid "is still associated with this entry" -msgstr "" - -msgid "are still associated with this entry" -msgstr "" - -## From Ecto.Changeset.validate_length/3 -msgid "should be %{count} character(s)" -msgid_plural "should be %{count} character(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should have %{count} item(s)" -msgid_plural "should have %{count} item(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should be at least %{count} character(s)" -msgid_plural "should be at least %{count} character(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should have at least %{count} item(s)" -msgid_plural "should have at least %{count} item(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should be at most %{count} character(s)" -msgid_plural "should be at most %{count} character(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should have at most %{count} item(s)" -msgid_plural "should have at most %{count} item(s)" -msgstr[0] "" -msgstr[1] "" - -## From Ecto.Changeset.validate_number/3 -msgid "must be less than %{number}" -msgstr "" - -msgid "must be greater than %{number}" -msgstr "" - -msgid "must be less than or equal to %{number}" -msgstr "" - -msgid "must be greater than or equal to %{number}" -msgstr "" - -msgid "must be equal to %{number}" -msgstr "" diff --git a/apps/auth_web/priv/gettext/errors.pot b/apps/auth_web/priv/gettext/errors.pot deleted file mode 100644 index 39a220be..00000000 --- a/apps/auth_web/priv/gettext/errors.pot +++ /dev/null @@ -1,95 +0,0 @@ -## This is a PO Template file. -## -## `msgid`s here are often extracted from source code. -## Add new translations manually only if they're dynamic -## translations that can't be statically extracted. -## -## Run `mix gettext.extract` to bring this file up to -## date. Leave `msgstr`s empty as changing them here has no -## effect: edit them in PO (`.po`) files instead. - -## From Ecto.Changeset.cast/4 -msgid "can't be blank" -msgstr "" - -## From Ecto.Changeset.unique_constraint/3 -msgid "has already been taken" -msgstr "" - -## From Ecto.Changeset.put_change/3 -msgid "is invalid" -msgstr "" - -## From Ecto.Changeset.validate_acceptance/3 -msgid "must be accepted" -msgstr "" - -## From Ecto.Changeset.validate_format/3 -msgid "has invalid format" -msgstr "" - -## From Ecto.Changeset.validate_subset/3 -msgid "has an invalid entry" -msgstr "" - -## From Ecto.Changeset.validate_exclusion/3 -msgid "is reserved" -msgstr "" - -## From Ecto.Changeset.validate_confirmation/3 -msgid "does not match confirmation" -msgstr "" - -## From Ecto.Changeset.no_assoc_constraint/3 -msgid "is still associated with this entry" -msgstr "" - -msgid "are still associated with this entry" -msgstr "" - -## From Ecto.Changeset.validate_length/3 -msgid "should be %{count} character(s)" -msgid_plural "should be %{count} character(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should have %{count} item(s)" -msgid_plural "should have %{count} item(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should be at least %{count} character(s)" -msgid_plural "should be at least %{count} character(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should have at least %{count} item(s)" -msgid_plural "should have at least %{count} item(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should be at most %{count} character(s)" -msgid_plural "should be at most %{count} character(s)" -msgstr[0] "" -msgstr[1] "" - -msgid "should have at most %{count} item(s)" -msgid_plural "should have at most %{count} item(s)" -msgstr[0] "" -msgstr[1] "" - -## From Ecto.Changeset.validate_number/3 -msgid "must be less than %{number}" -msgstr "" - -msgid "must be greater than %{number}" -msgstr "" - -msgid "must be less than or equal to %{number}" -msgstr "" - -msgid "must be greater than or equal to %{number}" -msgstr "" - -msgid "must be equal to %{number}" -msgstr "" diff --git a/apps/auth_web/test/support/channel_case.ex b/apps/auth_web/test/support/channel_case.ex deleted file mode 100644 index 0a0cdecd..00000000 --- a/apps/auth_web/test/support/channel_case.ex +++ /dev/null @@ -1,40 +0,0 @@ -defmodule AuthWeb.ChannelCase do - @moduledoc """ - This module defines the test case to be used by - channel tests. - - Such tests rely on `Phoenix.ChannelTest` and also - import other functionality to make it easier - to build common data structures and query the data layer. - - Finally, if the test case interacts with the database, - we enable the SQL sandbox, so changes done to the database - are reverted at the end of every test. If you are using - PostgreSQL, you can even run database tests asynchronously - by setting `use AuthWeb.ChannelCase, async: true`, although - this option is not recommended for other databases. - """ - - use ExUnit.CaseTemplate - - using do - quote do - # Import conveniences for testing with channels - import Phoenix.ChannelTest - import AuthWeb.ChannelCase - - # The default endpoint for testing - @endpoint AuthWeb.Endpoint - end - end - - setup tags do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(Auth.Repo) - - unless tags[:async] do - Ecto.Adapters.SQL.Sandbox.mode(Auth.Repo, {:shared, self()}) - end - - :ok - end -end diff --git a/apps/auth_web/test/support/conn_case.ex b/apps/auth_web/test/support/conn_case.ex deleted file mode 100644 index dc528c18..00000000 --- a/apps/auth_web/test/support/conn_case.ex +++ /dev/null @@ -1,43 +0,0 @@ -defmodule AuthWeb.ConnCase do - @moduledoc """ - This module defines the test case to be used by - tests that require setting up a connection. - - Such tests rely on `Phoenix.ConnTest` and also - import other functionality to make it easier - to build common data structures and query the data layer. - - Finally, if the test case interacts with the database, - we enable the SQL sandbox, so changes done to the database - are reverted at the end of every test. If you are using - PostgreSQL, you can even run database tests asynchronously - by setting `use AuthWeb.ConnCase, async: true`, although - this option is not recommended for other databases. - """ - - use ExUnit.CaseTemplate - - using do - quote do - # Import conveniences for testing with connections - import Plug.Conn - import Phoenix.ConnTest - import AuthWeb.ConnCase - - alias AuthWeb.Router.Helpers, as: Routes - - # The default endpoint for testing - @endpoint AuthWeb.Endpoint - end - end - - setup tags do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(Auth.Repo) - - unless tags[:async] do - Ecto.Adapters.SQL.Sandbox.mode(Auth.Repo, {:shared, self()}) - end - - {:ok, conn: Phoenix.ConnTest.build_conn()} - end -end diff --git a/apps/auth_web/test/test_helper.exs b/apps/auth_web/test/test_helper.exs deleted file mode 100644 index 26689cc8..00000000 --- a/apps/auth_web/test/test_helper.exs +++ /dev/null @@ -1,2 +0,0 @@ -ExUnit.start() -Ecto.Adapters.SQL.Sandbox.mode(Auth.Repo, :manual) diff --git a/apps/content/mix.exs b/apps/content/mix.exs index 938004ef..2422e620 100644 --- a/apps/content/mix.exs +++ b/apps/content/mix.exs @@ -39,8 +39,6 @@ defmodule Content.MixProject do # Type `mix help deps` for examples and options. defp deps do [ - {:auth, in_umbrella: true}, - {:auth_web, in_umbrella: true}, {:core, in_umbrella: true}, {:earmark, "1.4.3"}, {:excoveralls, "~> 0.10", only: [:dev, :test]}, diff --git a/apps/auth/lib/auth.ex b/apps/core/lib/auth.ex similarity index 100% rename from apps/auth/lib/auth.ex rename to apps/core/lib/auth.ex diff --git a/apps/auth/lib/auth/roles.ex b/apps/core/lib/auth/roles.ex similarity index 100% rename from apps/auth/lib/auth/roles.ex rename to apps/core/lib/auth/roles.ex diff --git a/apps/auth/lib/auth/user.ex b/apps/core/lib/auth/user.ex similarity index 100% rename from apps/auth/lib/auth/user.ex rename to apps/core/lib/auth/user.ex diff --git a/apps/auth/lib/auth/user_admin.ex b/apps/core/lib/auth/user_admin.ex similarity index 96% rename from apps/auth/lib/auth/user_admin.ex rename to apps/core/lib/auth/user_admin.ex index 405ebbc6..b069988e 100644 --- a/apps/auth/lib/auth/user_admin.ex +++ b/apps/core/lib/auth/user_admin.ex @@ -1,6 +1,7 @@ defmodule Auth.UserAdmin do import Ecto.Query, only: [from: 2] - alias Auth.{Repo,User} + alias Auth.User + alias Core.Repo def create_changeset(schema, attrs) do Auth.User.admin_changeset(schema, attrs) diff --git a/apps/auth_web/lib/auth_web.ex b/apps/core/lib/auth_web.ex similarity index 91% rename from apps/auth_web/lib/auth_web.ex rename to apps/core/lib/auth_web.ex index 292089d6..e75cc255 100644 --- a/apps/auth_web/lib/auth_web.ex +++ b/apps/core/lib/auth_web.ex @@ -22,8 +22,8 @@ defmodule AuthWeb do use Phoenix.Controller, namespace: AuthWeb import Plug.Conn - import AuthWeb.Gettext - alias AuthWeb.Router.Helpers, as: Routes + import CoreWeb.Gettext + alias CoreWeb.Router.Helpers, as: Routes end end @@ -54,7 +54,7 @@ defmodule AuthWeb do def channel do quote do use Phoenix.Channel - import AuthWeb.Gettext + import CoreWeb.Gettext end end @@ -68,8 +68,8 @@ defmodule AuthWeb do import CoreWeb.ErrorHelpers import CoreWeb.Helpers - import AuthWeb.Gettext - alias AuthWeb.Router.Helpers, as: Routes + import CoreWeb.Gettext + alias CoreWeb.Router.Helpers, as: Routes end end diff --git a/apps/auth_web/lib/auth_web/controllers/.keep b/apps/core/lib/auth_web/controllers/.keep similarity index 100% rename from apps/auth_web/lib/auth_web/controllers/.keep rename to apps/core/lib/auth_web/controllers/.keep diff --git a/apps/core/lib/auth_web/helpers.ex b/apps/core/lib/auth_web/helpers.ex new file mode 100644 index 00000000..b6ae5041 --- /dev/null +++ b/apps/core/lib/auth_web/helpers.ex @@ -0,0 +1,7 @@ +defmodule AuthWeb.Helpers do + def has_role?(conn = %Plug.Conn{}, role) do + conn + |> Pow.Plug.current_user() + |> Auth.Roles.has_role?(role) + end +end diff --git a/apps/auth_web/lib/auth_web/plugs/require_admin.ex b/apps/core/lib/auth_web/plugs/require_admin.ex similarity index 100% rename from apps/auth_web/lib/auth_web/plugs/require_admin.ex rename to apps/core/lib/auth_web/plugs/require_admin.ex diff --git a/apps/auth_web/lib/auth_web/pow/mailer.ex b/apps/core/lib/auth_web/pow/mailer.ex similarity index 100% rename from apps/auth_web/lib/auth_web/pow/mailer.ex rename to apps/core/lib/auth_web/pow/mailer.ex diff --git a/apps/auth_web/lib/auth_web/templates/email/pow_mail.html.eex b/apps/core/lib/auth_web/templates/email/pow_mail.html.eex similarity index 100% rename from apps/auth_web/lib/auth_web/templates/email/pow_mail.html.eex rename to apps/core/lib/auth_web/templates/email/pow_mail.html.eex diff --git a/apps/auth_web/lib/auth_web/templates/email/pow_mail.text.eex b/apps/core/lib/auth_web/templates/email/pow_mail.text.eex similarity index 100% rename from apps/auth_web/lib/auth_web/templates/email/pow_mail.text.eex rename to apps/core/lib/auth_web/templates/email/pow_mail.text.eex diff --git a/apps/auth_web/lib/auth_web/templates/page/index.html.eex b/apps/core/lib/auth_web/templates/page/index.html.eex similarity index 100% rename from apps/auth_web/lib/auth_web/templates/page/index.html.eex rename to apps/core/lib/auth_web/templates/page/index.html.eex diff --git a/apps/auth_web/lib/auth_web/templates/pow/registration/edit.html.eex b/apps/core/lib/auth_web/templates/pow/registration/edit.html.eex similarity index 100% rename from apps/auth_web/lib/auth_web/templates/pow/registration/edit.html.eex rename to apps/core/lib/auth_web/templates/pow/registration/edit.html.eex diff --git a/apps/auth_web/lib/auth_web/templates/pow/registration/new.html.eex b/apps/core/lib/auth_web/templates/pow/registration/new.html.eex similarity index 100% rename from apps/auth_web/lib/auth_web/templates/pow/registration/new.html.eex rename to apps/core/lib/auth_web/templates/pow/registration/new.html.eex diff --git a/apps/auth_web/lib/auth_web/templates/pow/session/new.html.eex b/apps/core/lib/auth_web/templates/pow/session/new.html.eex similarity index 100% rename from apps/auth_web/lib/auth_web/templates/pow/session/new.html.eex rename to apps/core/lib/auth_web/templates/pow/session/new.html.eex diff --git a/apps/auth_web/lib/auth_web/templates/pow_email_confirmation/mailer/email_confirmation.html.eex b/apps/core/lib/auth_web/templates/pow_email_confirmation/mailer/email_confirmation.html.eex similarity index 100% rename from apps/auth_web/lib/auth_web/templates/pow_email_confirmation/mailer/email_confirmation.html.eex rename to apps/core/lib/auth_web/templates/pow_email_confirmation/mailer/email_confirmation.html.eex diff --git a/apps/auth_web/lib/auth_web/templates/pow_email_confirmation/mailer/email_confirmation.text.eex b/apps/core/lib/auth_web/templates/pow_email_confirmation/mailer/email_confirmation.text.eex similarity index 100% rename from apps/auth_web/lib/auth_web/templates/pow_email_confirmation/mailer/email_confirmation.text.eex rename to apps/core/lib/auth_web/templates/pow_email_confirmation/mailer/email_confirmation.text.eex diff --git a/apps/auth_web/lib/auth_web/templates/pow_reset_password/mailer/reset_password.html.eex b/apps/core/lib/auth_web/templates/pow_reset_password/mailer/reset_password.html.eex similarity index 100% rename from apps/auth_web/lib/auth_web/templates/pow_reset_password/mailer/reset_password.html.eex rename to apps/core/lib/auth_web/templates/pow_reset_password/mailer/reset_password.html.eex diff --git a/apps/auth_web/lib/auth_web/templates/pow_reset_password/mailer/reset_password.text.eex b/apps/core/lib/auth_web/templates/pow_reset_password/mailer/reset_password.text.eex similarity index 100% rename from apps/auth_web/lib/auth_web/templates/pow_reset_password/mailer/reset_password.text.eex rename to apps/core/lib/auth_web/templates/pow_reset_password/mailer/reset_password.text.eex diff --git a/apps/auth_web/lib/auth_web/templates/pow_reset_password/reset_password/edit.html.eex b/apps/core/lib/auth_web/templates/pow_reset_password/reset_password/edit.html.eex similarity index 100% rename from apps/auth_web/lib/auth_web/templates/pow_reset_password/reset_password/edit.html.eex rename to apps/core/lib/auth_web/templates/pow_reset_password/reset_password/edit.html.eex diff --git a/apps/auth_web/lib/auth_web/templates/pow_reset_password/reset_password/new.html.eex b/apps/core/lib/auth_web/templates/pow_reset_password/reset_password/new.html.eex similarity index 100% rename from apps/auth_web/lib/auth_web/templates/pow_reset_password/reset_password/new.html.eex rename to apps/core/lib/auth_web/templates/pow_reset_password/reset_password/new.html.eex diff --git a/apps/auth_web/lib/auth_web/views/error_view.ex b/apps/core/lib/auth_web/views/error_view.ex similarity index 100% rename from apps/auth_web/lib/auth_web/views/error_view.ex rename to apps/core/lib/auth_web/views/error_view.ex diff --git a/apps/auth_web/lib/auth_web/views/layout_view.ex b/apps/core/lib/auth_web/views/layout_view.ex similarity index 100% rename from apps/auth_web/lib/auth_web/views/layout_view.ex rename to apps/core/lib/auth_web/views/layout_view.ex diff --git a/apps/auth_web/lib/auth_web/views/page_view.ex b/apps/core/lib/auth_web/views/page_view.ex similarity index 100% rename from apps/auth_web/lib/auth_web/views/page_view.ex rename to apps/core/lib/auth_web/views/page_view.ex diff --git a/apps/auth_web/lib/auth_web/views/pow/email_view.ex b/apps/core/lib/auth_web/views/pow/email_view.ex similarity index 100% rename from apps/auth_web/lib/auth_web/views/pow/email_view.ex rename to apps/core/lib/auth_web/views/pow/email_view.ex diff --git a/apps/auth_web/lib/auth_web/views/pow/registration_view.ex b/apps/core/lib/auth_web/views/pow/registration_view.ex similarity index 100% rename from apps/auth_web/lib/auth_web/views/pow/registration_view.ex rename to apps/core/lib/auth_web/views/pow/registration_view.ex diff --git a/apps/auth_web/lib/auth_web/views/pow/session_view.ex b/apps/core/lib/auth_web/views/pow/session_view.ex similarity index 100% rename from apps/auth_web/lib/auth_web/views/pow/session_view.ex rename to apps/core/lib/auth_web/views/pow/session_view.ex diff --git a/apps/auth_web/lib/auth_web/views/pow_email_confirmation/mailer_view.ex b/apps/core/lib/auth_web/views/pow_email_confirmation/mailer_view.ex similarity index 100% rename from apps/auth_web/lib/auth_web/views/pow_email_confirmation/mailer_view.ex rename to apps/core/lib/auth_web/views/pow_email_confirmation/mailer_view.ex diff --git a/apps/auth_web/lib/auth_web/views/pow_reset_password/mailer_view.ex b/apps/core/lib/auth_web/views/pow_reset_password/mailer_view.ex similarity index 100% rename from apps/auth_web/lib/auth_web/views/pow_reset_password/mailer_view.ex rename to apps/core/lib/auth_web/views/pow_reset_password/mailer_view.ex diff --git a/apps/auth_web/lib/auth_web/views/pow_reset_password/reset_password_view.ex b/apps/core/lib/auth_web/views/pow_reset_password/reset_password_view.ex similarity index 100% rename from apps/auth_web/lib/auth_web/views/pow_reset_password/reset_password_view.ex rename to apps/core/lib/auth_web/views/pow_reset_password/reset_password_view.ex diff --git a/apps/core/lib/core/application.ex b/apps/core/lib/core/application.ex index 24223f3e..4ca742af 100644 --- a/apps/core/lib/core/application.ex +++ b/apps/core/lib/core/application.ex @@ -14,7 +14,7 @@ defmodule Core.Application do # Start the PubSub system {Phoenix.PubSub, name: Core.PubSub}, # Start the Endpoint (http/https) - CoreWeb.Endpoint + CoreWeb.Endpoint, # Start a worker by calling: Core.Worker.start_link(arg) # {Core.Worker, arg} ] diff --git a/apps/core/lib/core_web.ex b/apps/core/lib/core_web.ex index 60c2804f..79433cd4 100644 --- a/apps/core/lib/core_web.ex +++ b/apps/core/lib/core_web.ex @@ -74,6 +74,16 @@ defmodule CoreWeb do end end + def mailer_view do + quote do + use Phoenix.View, root: "lib/auth_web/templates", + namespace: AuthWeb + + use Phoenix.HTML + import CoreWeb.EmailHelpers + end + end + @doc """ When used, dispatch to the appropriate controller/view/etc. """ diff --git a/apps/core/lib/core_web/endpoint.ex b/apps/core/lib/core_web/endpoint.ex index 9df7c2e4..f92d6a16 100644 --- a/apps/core/lib/core_web/endpoint.ex +++ b/apps/core/lib/core_web/endpoint.ex @@ -56,7 +56,7 @@ defmodule CoreWeb.Endpoint do plug Plug.MethodOverride plug Plug.Head plug Plug.Session, @session_options - plug Pow.Plug.Session, otp_app: :auth_web + plug Pow.Plug.Session, otp_app: :core plug PowPersistentSession.Plug.Cookie plug CoreWeb.Router end diff --git a/apps/core/lib/core_web/router.ex b/apps/core/lib/core_web/router.ex index 57aeb284..0b7cc87c 100644 --- a/apps/core/lib/core_web/router.ex +++ b/apps/core/lib/core_web/router.ex @@ -1,5 +1,8 @@ defmodule CoreWeb.Router do use CoreWeb, :router + use Pow.Phoenix.Router + use Pow.Extension.Phoenix.Router, + extensions: [PowResetPassword, PowEmailConfirmation] pipeline :browser do plug :accepts, ["html"] @@ -13,6 +16,13 @@ defmodule CoreWeb.Router do plug :accepts, ["json"] end + scope "/" do + pipe_through :browser + + pow_routes() + pow_extension_routes() + end + if Mix.env() in [:dev, :test] do import Phoenix.LiveDashboard.Router diff --git a/apps/core/lib/core_web/views/helpers.ex b/apps/core/lib/core_web/views/helpers.ex index 22a78a09..8a6a7252 100644 --- a/apps/core/lib/core_web/views/helpers.ex +++ b/apps/core/lib/core_web/views/helpers.ex @@ -187,7 +187,7 @@ defmodule CoreWeb.Helpers do end def pow_extension_enabled?(extension) do - {extensions, _rest} = Application.get_env(:auth_web, :pow) |> Keyword.pop(:extensions, []) + {extensions, _rest} = Application.get_env(:core, :pow) |> Keyword.pop(:extensions, []) Enum.any?(extensions, & &1 == extension) end diff --git a/apps/auth/lib/mix/tasks/create_admin.ex b/apps/core/lib/mix/tasks/create_admin.ex similarity index 93% rename from apps/auth/lib/mix/tasks/create_admin.ex rename to apps/core/lib/mix/tasks/create_admin.ex index b0d7e5fe..5450db0c 100644 --- a/apps/auth/lib/mix/tasks/create_admin.ex +++ b/apps/core/lib/mix/tasks/create_admin.ex @@ -5,12 +5,12 @@ defmodule Mix.Tasks.Legendary.CreateAdmin do use Mix.Task alias Auth.User - alias Auth.Repo + alias Core.Repo alias Ecto.Changeset @shortdoc "Create an admin user." def run(_) do - Application.ensure_all_started(:auth) + Application.ensure_all_started(:core) email = ExPrompt.string_required("Email: ") password = ExPrompt.password("Password: ") diff --git a/apps/core/mix.exs b/apps/core/mix.exs index 7fd6c7d4..d25aef7e 100644 --- a/apps/core/mix.exs +++ b/apps/core/mix.exs @@ -39,7 +39,6 @@ defmodule Core.MixProject do # Type `mix help deps` for examples and options. defp deps do [ - {:auth, in_umbrella: true}, {:bamboo, "~> 1.5"}, {:credo, "~> 1.4", only: [:dev, :test], runtime: false}, {:ex_cldr, "~> 2.13.0"}, @@ -47,11 +46,13 @@ defmodule Core.MixProject do {:phoenix, "~> 1.5.3"}, {:phoenix_ecto, "~> 4.1"}, {:ecto_sql, "~> 3.4"}, + {:ex_prompt, "~> 0.1.5"}, {:linguist, "0.3.1"}, {:postgrex, ">= 0.0.0"}, {:phoenix_html, "~> 2.11"}, {:phoenix_live_reload, "~> 1.2", only: :dev}, {:phoenix_live_dashboard, "~> 0.2.0"}, + {:phoenix_pubsub, "~> 2.0"}, {:pow, "~> 1.0.20"}, {:telemetry_metrics, "~> 0.4"}, {:telemetry_poller, "~> 0.4"}, diff --git a/apps/auth/priv/repo/migrations/20200714154549_create_users.exs b/apps/core/priv/repo/migrations/20200714154549_create_users.exs similarity index 82% rename from apps/auth/priv/repo/migrations/20200714154549_create_users.exs rename to apps/core/priv/repo/migrations/20200714154549_create_users.exs index 236afe2a..e41e6276 100644 --- a/apps/auth/priv/repo/migrations/20200714154549_create_users.exs +++ b/apps/core/priv/repo/migrations/20200714154549_create_users.exs @@ -1,4 +1,4 @@ -defmodule Auth.Repo.Migrations.CreateUsers do +defmodule Core.Repo.Migrations.CreateUsers do use Ecto.Migration def change do diff --git a/apps/auth/priv/repo/migrations/20200715221321_add_pow_email_confirmation_to_users.exs b/apps/core/priv/repo/migrations/20200715221321_add_pow_email_confirmation_to_users.exs similarity index 81% rename from apps/auth/priv/repo/migrations/20200715221321_add_pow_email_confirmation_to_users.exs rename to apps/core/priv/repo/migrations/20200715221321_add_pow_email_confirmation_to_users.exs index 76e2f8c8..75c535f1 100644 --- a/apps/auth/priv/repo/migrations/20200715221321_add_pow_email_confirmation_to_users.exs +++ b/apps/core/priv/repo/migrations/20200715221321_add_pow_email_confirmation_to_users.exs @@ -1,4 +1,4 @@ -defmodule Auth.Repo.Migrations.AddPowEmailConfirmationToUsers do +defmodule Core.Repo.Migrations.AddPowEmailConfirmationToUsers do use Ecto.Migration def change do diff --git a/apps/auth/priv/repo/migrations/20200717182733_add_roles_to_users.exs b/apps/core/priv/repo/migrations/20200717182733_add_roles_to_users.exs similarity index 72% rename from apps/auth/priv/repo/migrations/20200717182733_add_roles_to_users.exs rename to apps/core/priv/repo/migrations/20200717182733_add_roles_to_users.exs index 385bd56d..25ab058e 100644 --- a/apps/auth/priv/repo/migrations/20200717182733_add_roles_to_users.exs +++ b/apps/core/priv/repo/migrations/20200717182733_add_roles_to_users.exs @@ -1,4 +1,4 @@ -defmodule Auth.Repo.Migrations.AddRolesToUsers do +defmodule Core.Repo.Migrations.AddRolesToUsers do use Ecto.Migration def change do diff --git a/apps/auth/priv/repo/migrations/20200721214958_add_nicename_to_users.exs b/apps/core/priv/repo/migrations/20200721214958_add_nicename_to_users.exs similarity index 71% rename from apps/auth/priv/repo/migrations/20200721214958_add_nicename_to_users.exs rename to apps/core/priv/repo/migrations/20200721214958_add_nicename_to_users.exs index 819daa8e..d1b88370 100644 --- a/apps/auth/priv/repo/migrations/20200721214958_add_nicename_to_users.exs +++ b/apps/core/priv/repo/migrations/20200721214958_add_nicename_to_users.exs @@ -1,4 +1,4 @@ -defmodule Auth.Repo.Migrations.AddNicenameToUsers do +defmodule Core.Repo.Migrations.AddNicenameToUsers do use Ecto.Migration def change do diff --git a/apps/auth/priv/repo/migrations/20200721215212_add_url_to_users.exs b/apps/core/priv/repo/migrations/20200721215212_add_url_to_users.exs similarity index 73% rename from apps/auth/priv/repo/migrations/20200721215212_add_url_to_users.exs rename to apps/core/priv/repo/migrations/20200721215212_add_url_to_users.exs index 585ab333..de433a16 100644 --- a/apps/auth/priv/repo/migrations/20200721215212_add_url_to_users.exs +++ b/apps/core/priv/repo/migrations/20200721215212_add_url_to_users.exs @@ -1,4 +1,4 @@ -defmodule Auth.Repo.Migrations.AddUrlToUsers do +defmodule Core.Repo.Migrations.AddUrlToUsers do use Ecto.Migration def change do diff --git a/apps/auth/test/auth/roles_test.exs b/apps/core/test/auth/roles_test.exs similarity index 96% rename from apps/auth/test/auth/roles_test.exs rename to apps/core/test/auth/roles_test.exs index ab0bb5db..afccc273 100644 --- a/apps/auth/test/auth/roles_test.exs +++ b/apps/core/test/auth/roles_test.exs @@ -1,5 +1,5 @@ defmodule Auth.RolesTest do - use Auth.DataCase + use Core.DataCase import Auth.Roles diff --git a/apps/auth/test/auth/user_test.exs b/apps/core/test/auth/user_test.exs similarity index 97% rename from apps/auth/test/auth/user_test.exs rename to apps/core/test/auth/user_test.exs index b9af9950..17e1c17e 100644 --- a/apps/auth/test/auth/user_test.exs +++ b/apps/core/test/auth/user_test.exs @@ -1,5 +1,5 @@ defmodule Auth.UserTest do - use Auth.DataCase + use Core.DataCase import Auth.User diff --git a/apps/auth_web/test/auth_web/controllers/.keep b/apps/core/test/auth_web/controllers/.keep similarity index 100% rename from apps/auth_web/test/auth_web/controllers/.keep rename to apps/core/test/auth_web/controllers/.keep diff --git a/apps/core/test/auth_web/helpers_test.exs b/apps/core/test/auth_web/helpers_test.exs new file mode 100644 index 00000000..7c3f911f --- /dev/null +++ b/apps/core/test/auth_web/helpers_test.exs @@ -0,0 +1,25 @@ +defmodule AuthWeb.HelpersTest do + use CoreWeb.ConnCase + + import AuthWeb.Helpers + + describe "has_role?/2" do + test "with a user", %{conn: conn} do + conn = + conn + |> Pow.Plug.put_config(current_user_assigns_key: :current_user) + |> Pow.Plug.assign_current_user(%Auth.User{roles: ["admin"]}, []) + + assert has_role?(conn, "admin") + refute has_role?(conn, "blooper") + end + + test "without a user", %{conn: conn} do + conn = + conn + |> Pow.Plug.put_config(current_user_assigns_key: :current_user) + + refute has_role?(conn, "admin") + end + end +end diff --git a/apps/auth_web/test/auth_web/plugs/require_admin_test.exs b/apps/core/test/auth_web/plugs/require_admin_test.exs similarity index 96% rename from apps/auth_web/test/auth_web/plugs/require_admin_test.exs rename to apps/core/test/auth_web/plugs/require_admin_test.exs index 461a4599..7cd976a4 100644 --- a/apps/auth_web/test/auth_web/plugs/require_admin_test.exs +++ b/apps/core/test/auth_web/plugs/require_admin_test.exs @@ -1,5 +1,5 @@ defmodule AuthWeb.Plugs.RequireAdminTest do - use AuthWeb.ConnCase + use CoreWeb.ConnCase alias AuthWeb.Plugs.RequireAdmin alias Auth.User diff --git a/apps/auth_web/test/auth_web/pow/mailer_test.exs b/apps/core/test/auth_web/pow/mailer_test.exs similarity index 100% rename from apps/auth_web/test/auth_web/pow/mailer_test.exs rename to apps/core/test/auth_web/pow/mailer_test.exs diff --git a/apps/auth_web/test/auth_web/views/error_view_test.exs b/apps/core/test/auth_web/views/error_view_test.exs similarity index 91% rename from apps/auth_web/test/auth_web/views/error_view_test.exs rename to apps/core/test/auth_web/views/error_view_test.exs index da2d4a6a..5ca0cd6e 100644 --- a/apps/auth_web/test/auth_web/views/error_view_test.exs +++ b/apps/core/test/auth_web/views/error_view_test.exs @@ -1,5 +1,5 @@ defmodule AuthWeb.ErrorViewTest do - use AuthWeb.ConnCase, async: true + use CoreWeb.ConnCase, async: true # Bring render/3 and render_to_string/3 for testing custom views import Phoenix.View diff --git a/apps/auth_web/test/auth_web/views/layout_view_test.exs b/apps/core/test/auth_web/views/layout_view_test.exs similarity index 86% rename from apps/auth_web/test/auth_web/views/layout_view_test.exs rename to apps/core/test/auth_web/views/layout_view_test.exs index 1b8a790d..abbfd642 100644 --- a/apps/auth_web/test/auth_web/views/layout_view_test.exs +++ b/apps/core/test/auth_web/views/layout_view_test.exs @@ -1,5 +1,5 @@ defmodule AuthWeb.LayoutViewTest do - use AuthWeb.ConnCase, async: true + use CoreWeb.ConnCase, async: true # When testing helpers, you may want to import Phoenix.HTML and # use functions such as safe_to_string() to convert the helper diff --git a/apps/auth_web/test/auth_web/views/page_view_test.exs b/apps/core/test/auth_web/views/page_view_test.exs similarity index 51% rename from apps/auth_web/test/auth_web/views/page_view_test.exs rename to apps/core/test/auth_web/views/page_view_test.exs index cc88c840..c2c20457 100644 --- a/apps/auth_web/test/auth_web/views/page_view_test.exs +++ b/apps/core/test/auth_web/views/page_view_test.exs @@ -1,3 +1,3 @@ defmodule AuthWeb.PageViewTest do - use AuthWeb.ConnCase, async: true + use CoreWeb.ConnCase, async: true end diff --git a/config/config.exs b/config/config.exs index 67c22e49..8a3817d5 100644 --- a/config/config.exs +++ b/config/config.exs @@ -3,7 +3,7 @@ use Mix.Config [ {:admin, Admin, false}, {:app, AppWeb, true}, - {:auth_web, AuthWeb, false}, + {:core, AuthWeb, false}, {:content, Content, false}, {:core, CoreWeb, false}, ] @@ -12,19 +12,17 @@ use Mix.Config error_view = Module.concat(module, "ErrorView") config otp_app, endpoint, - url: [host: "localhost"], - secret_key_base: "r2eN53mJ9RmlGz9ZQ7xf43P3Or59aaO9rdf5D3hRcsuiH44pGW9kPGfl5mt9N1Gi", - render_errors: [view: error_view, accepts: ~w(html json), layout: false], - pubsub_server: App.PubSub, - live_view: [signing_salt: "g5ltUbnQ"], - server: start_server + url: [host: "localhost"], + secret_key_base: "r2eN53mJ9RmlGz9ZQ7xf43P3Or59aaO9rdf5D3hRcsuiH44pGW9kPGfl5mt9N1Gi", + render_errors: [view: error_view, accepts: ~w(html json), layout: false], + pubsub_server: App.PubSub, + live_view: [signing_salt: "g5ltUbnQ"], + server: start_server end) [ {:admin, Admin.Repo}, {:app, App.Repo}, - {:auth, Auth.Repo}, - {:auth_web, Auth.Repo, :auth}, {:content, Content.Repo}, {:core, Core.Repo}, ] @@ -40,9 +38,9 @@ end) generators: [context_app: context_app] end) -config :auth_web, :pow, +config :core, :pow, user: Auth.User, - repo: Auth.Repo, + repo: Core.Repo, extensions: [PowEmailConfirmation, PowPersistentSession, PowResetPassword], controller_callbacks: Pow.Extension.Phoenix.ControllerCallbacks, mailer_backend: AuthWeb.Pow.Mailer, diff --git a/config/dev.exs b/config/dev.exs index 77548d61..7c58cba3 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -9,7 +9,7 @@ use Mix.Config [ {:admin, Admin}, {:app, AppWeb}, - {:auth_web, AuthWeb}, + {:core, AuthWeb}, {:content, Content}, {:core, CoreWeb}, ] @@ -43,7 +43,6 @@ end) [ {:admin, Admin.Repo}, {:app, App.Repo}, - {:auth, Auth.Repo}, {:content, Content.Repo}, {:core, Core.Repo} ] diff --git a/config/prod.exs b/config/prod.exs index ae78fe47..4bf46947 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -17,10 +17,6 @@ config :admin, Admin.Endpoint, url: [host: "example.com", port: 80], cache_static_manifest: "priv/static/cache_manifest.json" -config :auth_web, AuthWeb.Endpoint, - url: [host: "example.com", port: 80], - cache_static_manifest: "priv/static/cache_manifest.json" - config :content, Content.Endpoint, url: [host: "example.com", port: 80], cache_static_manifest: "priv/static/cache_manifest.json" diff --git a/config/test.exs b/config/test.exs index 4c031c56..f63bc104 100644 --- a/config/test.exs +++ b/config/test.exs @@ -5,7 +5,7 @@ use Mix.Config [ {:admin, Admin}, {:app, AppWeb}, - {:auth_web, AuthWeb}, + {:core, AuthWeb}, {:content, Content}, {:core, CoreWeb}, ] @@ -24,7 +24,6 @@ end) [ {:admin, Admin.Repo}, {:app, App.Repo}, - {:auth, Auth.Repo}, {:content, Content.Repo}, {:core, Core.Repo} ]