Merge branch 'auth-apps-rollup' into 'master'
chore: Move auth module under core See merge request mythic-insight/legendary!23
This commit is contained in:
		
						commit
						ed0ceb9460
					
				
					 83 changed files with 89 additions and 868 deletions
				
			
		| 
						 | 
					@ -39,7 +39,6 @@ defmodule Admin.MixProject do
 | 
				
			||||||
  # Type `mix help deps` for examples and options.
 | 
					  # Type `mix help deps` for examples and options.
 | 
				
			||||||
  defp deps do
 | 
					  defp deps do
 | 
				
			||||||
    [
 | 
					    [
 | 
				
			||||||
      {:auth_web, in_umbrella: true},
 | 
					 | 
				
			||||||
      {:core, in_umbrella: true},
 | 
					      {:core, in_umbrella: true},
 | 
				
			||||||
      {:ecto_sql, "~> 3.4"},
 | 
					      {:ecto_sql, "~> 3.4"},
 | 
				
			||||||
      {:excoveralls, "~> 0.10", only: [:dev, :test]},
 | 
					      {:excoveralls, "~> 0.10", only: [:dev, :test]},
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -56,7 +56,7 @@ defmodule AppWeb.Endpoint do
 | 
				
			||||||
  plug Plug.MethodOverride
 | 
					  plug Plug.MethodOverride
 | 
				
			||||||
  plug Plug.Head
 | 
					  plug Plug.Head
 | 
				
			||||||
  plug Plug.Session, @session_options
 | 
					  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 PowPersistentSession.Plug.Cookie
 | 
				
			||||||
  plug AppWeb.Router
 | 
					  plug AppWeb.Router
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +0,0 @@
 | 
				
			||||||
[
 | 
					 | 
				
			||||||
  import_deps: [:ecto],
 | 
					 | 
				
			||||||
  inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"],
 | 
					 | 
				
			||||||
  subdirectories: ["priv/*/migrations"]
 | 
					 | 
				
			||||||
]
 | 
					 | 
				
			||||||
							
								
								
									
										23
									
								
								apps/auth/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										23
									
								
								apps/auth/.gitignore
									
									
									
									
										vendored
									
									
								
							| 
						 | 
					@ -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
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,3 +0,0 @@
 | 
				
			||||||
# Auth
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
**TODO: Add description**
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,5 +0,0 @@
 | 
				
			||||||
defmodule Auth.Repo do
 | 
					 | 
				
			||||||
  use Ecto.Repo,
 | 
					 | 
				
			||||||
    otp_app: :auth,
 | 
					 | 
				
			||||||
    adapter: Ecto.Adapters.Postgres
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,4 +0,0 @@
 | 
				
			||||||
[
 | 
					 | 
				
			||||||
  import_deps: [:ecto_sql],
 | 
					 | 
				
			||||||
  inputs: ["*.exs"]
 | 
					 | 
				
			||||||
]
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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.
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,2 +0,0 @@
 | 
				
			||||||
ExUnit.start()
 | 
					 | 
				
			||||||
Ecto.Adapters.SQL.Sandbox.mode(Auth.Repo, :manual)
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,4 +0,0 @@
 | 
				
			||||||
[
 | 
					 | 
				
			||||||
  import_deps: [:phoenix],
 | 
					 | 
				
			||||||
  inputs: ["*.{ex,exs}", "{config,lib,test}/**/*.{ex,exs}"]
 | 
					 | 
				
			||||||
]
 | 
					 | 
				
			||||||
							
								
								
									
										34
									
								
								apps/auth_web/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										34
									
								
								apps/auth_web/.gitignore
									
									
									
									
										vendored
									
									
								
							| 
						 | 
					@ -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/
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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 ""
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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 ""
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,2 +0,0 @@
 | 
				
			||||||
ExUnit.start()
 | 
					 | 
				
			||||||
Ecto.Adapters.SQL.Sandbox.mode(Auth.Repo, :manual)
 | 
					 | 
				
			||||||
| 
						 | 
					@ -39,8 +39,6 @@ defmodule Content.MixProject do
 | 
				
			||||||
  # Type `mix help deps` for examples and options.
 | 
					  # Type `mix help deps` for examples and options.
 | 
				
			||||||
  defp deps do
 | 
					  defp deps do
 | 
				
			||||||
    [
 | 
					    [
 | 
				
			||||||
      {:auth, in_umbrella: true},
 | 
					 | 
				
			||||||
      {:auth_web, in_umbrella: true},
 | 
					 | 
				
			||||||
      {:core, in_umbrella: true},
 | 
					      {:core, in_umbrella: true},
 | 
				
			||||||
      {:earmark, "1.4.3"},
 | 
					      {:earmark, "1.4.3"},
 | 
				
			||||||
      {:excoveralls, "~> 0.10", only: [:dev, :test]},
 | 
					      {:excoveralls, "~> 0.10", only: [:dev, :test]},
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
defmodule Auth.UserAdmin do
 | 
					defmodule Auth.UserAdmin do
 | 
				
			||||||
  import Ecto.Query, only: [from: 2]
 | 
					  import Ecto.Query, only: [from: 2]
 | 
				
			||||||
  alias Auth.{Repo,User}
 | 
					  alias Auth.User
 | 
				
			||||||
 | 
					  alias Core.Repo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def create_changeset(schema, attrs) do
 | 
					  def create_changeset(schema, attrs) do
 | 
				
			||||||
    Auth.User.admin_changeset(schema, attrs)
 | 
					    Auth.User.admin_changeset(schema, attrs)
 | 
				
			||||||
| 
						 | 
					@ -22,8 +22,8 @@ defmodule AuthWeb do
 | 
				
			||||||
      use Phoenix.Controller, namespace: AuthWeb
 | 
					      use Phoenix.Controller, namespace: AuthWeb
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      import Plug.Conn
 | 
					      import Plug.Conn
 | 
				
			||||||
      import AuthWeb.Gettext
 | 
					      import CoreWeb.Gettext
 | 
				
			||||||
      alias AuthWeb.Router.Helpers, as: Routes
 | 
					      alias CoreWeb.Router.Helpers, as: Routes
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,7 +54,7 @@ defmodule AuthWeb do
 | 
				
			||||||
  def channel do
 | 
					  def channel do
 | 
				
			||||||
    quote do
 | 
					    quote do
 | 
				
			||||||
      use Phoenix.Channel
 | 
					      use Phoenix.Channel
 | 
				
			||||||
      import AuthWeb.Gettext
 | 
					      import CoreWeb.Gettext
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,8 +68,8 @@ defmodule AuthWeb do
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      import CoreWeb.ErrorHelpers
 | 
					      import CoreWeb.ErrorHelpers
 | 
				
			||||||
      import CoreWeb.Helpers
 | 
					      import CoreWeb.Helpers
 | 
				
			||||||
      import AuthWeb.Gettext
 | 
					      import CoreWeb.Gettext
 | 
				
			||||||
      alias AuthWeb.Router.Helpers, as: Routes
 | 
					      alias CoreWeb.Router.Helpers, as: Routes
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										7
									
								
								apps/core/lib/auth_web/helpers.ex
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								apps/core/lib/auth_web/helpers.ex
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -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
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,7 @@ defmodule Core.Application do
 | 
				
			||||||
      # Start the PubSub system
 | 
					      # Start the PubSub system
 | 
				
			||||||
      {Phoenix.PubSub, name: Core.PubSub},
 | 
					      {Phoenix.PubSub, name: Core.PubSub},
 | 
				
			||||||
      # Start the Endpoint (http/https)
 | 
					      # Start the Endpoint (http/https)
 | 
				
			||||||
      CoreWeb.Endpoint
 | 
					      CoreWeb.Endpoint,
 | 
				
			||||||
      # Start a worker by calling: Core.Worker.start_link(arg)
 | 
					      # Start a worker by calling: Core.Worker.start_link(arg)
 | 
				
			||||||
      # {Core.Worker, arg}
 | 
					      # {Core.Worker, arg}
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -74,6 +74,16 @@ defmodule CoreWeb do
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  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 """
 | 
					  @doc """
 | 
				
			||||||
  When used, dispatch to the appropriate controller/view/etc.
 | 
					  When used, dispatch to the appropriate controller/view/etc.
 | 
				
			||||||
  """
 | 
					  """
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -56,7 +56,7 @@ defmodule CoreWeb.Endpoint do
 | 
				
			||||||
  plug Plug.MethodOverride
 | 
					  plug Plug.MethodOverride
 | 
				
			||||||
  plug Plug.Head
 | 
					  plug Plug.Head
 | 
				
			||||||
  plug Plug.Session, @session_options
 | 
					  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 PowPersistentSession.Plug.Cookie
 | 
				
			||||||
  plug CoreWeb.Router
 | 
					  plug CoreWeb.Router
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,8 @@
 | 
				
			||||||
defmodule CoreWeb.Router do
 | 
					defmodule CoreWeb.Router do
 | 
				
			||||||
  use CoreWeb, :router
 | 
					  use CoreWeb, :router
 | 
				
			||||||
 | 
					  use Pow.Phoenix.Router
 | 
				
			||||||
 | 
					  use Pow.Extension.Phoenix.Router,
 | 
				
			||||||
 | 
					    extensions: [PowResetPassword, PowEmailConfirmation]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pipeline :browser do
 | 
					  pipeline :browser do
 | 
				
			||||||
    plug :accepts, ["html"]
 | 
					    plug :accepts, ["html"]
 | 
				
			||||||
| 
						 | 
					@ -13,6 +16,13 @@ defmodule CoreWeb.Router do
 | 
				
			||||||
    plug :accepts, ["json"]
 | 
					    plug :accepts, ["json"]
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  scope "/" do
 | 
				
			||||||
 | 
					    pipe_through :browser
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pow_routes()
 | 
				
			||||||
 | 
					    pow_extension_routes()
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if Mix.env() in [:dev, :test] do
 | 
					  if Mix.env() in [:dev, :test] do
 | 
				
			||||||
    import Phoenix.LiveDashboard.Router
 | 
					    import Phoenix.LiveDashboard.Router
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -187,7 +187,7 @@ defmodule CoreWeb.Helpers do
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def pow_extension_enabled?(extension) do
 | 
					  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)
 | 
					    Enum.any?(extensions, & &1 == extension)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,12 +5,12 @@ defmodule Mix.Tasks.Legendary.CreateAdmin do
 | 
				
			||||||
  use Mix.Task
 | 
					  use Mix.Task
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  alias Auth.User
 | 
					  alias Auth.User
 | 
				
			||||||
  alias Auth.Repo
 | 
					  alias Core.Repo
 | 
				
			||||||
  alias Ecto.Changeset
 | 
					  alias Ecto.Changeset
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @shortdoc "Create an admin user."
 | 
					  @shortdoc "Create an admin user."
 | 
				
			||||||
  def run(_) do
 | 
					  def run(_) do
 | 
				
			||||||
    Application.ensure_all_started(:auth)
 | 
					    Application.ensure_all_started(:core)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    email = ExPrompt.string_required("Email: ")
 | 
					    email = ExPrompt.string_required("Email: ")
 | 
				
			||||||
    password = ExPrompt.password("Password: ")
 | 
					    password = ExPrompt.password("Password: ")
 | 
				
			||||||
| 
						 | 
					@ -39,7 +39,6 @@ defmodule Core.MixProject do
 | 
				
			||||||
  # Type `mix help deps` for examples and options.
 | 
					  # Type `mix help deps` for examples and options.
 | 
				
			||||||
  defp deps do
 | 
					  defp deps do
 | 
				
			||||||
    [
 | 
					    [
 | 
				
			||||||
      {:auth, in_umbrella: true},
 | 
					 | 
				
			||||||
      {:bamboo, "~> 1.5"},
 | 
					      {:bamboo, "~> 1.5"},
 | 
				
			||||||
      {:credo, "~> 1.4", only: [:dev, :test], runtime: false},
 | 
					      {:credo, "~> 1.4", only: [:dev, :test], runtime: false},
 | 
				
			||||||
      {:ex_cldr, "~> 2.13.0"},
 | 
					      {:ex_cldr, "~> 2.13.0"},
 | 
				
			||||||
| 
						 | 
					@ -47,11 +46,13 @@ defmodule Core.MixProject do
 | 
				
			||||||
      {:phoenix, "~> 1.5.3"},
 | 
					      {:phoenix, "~> 1.5.3"},
 | 
				
			||||||
      {:phoenix_ecto, "~> 4.1"},
 | 
					      {:phoenix_ecto, "~> 4.1"},
 | 
				
			||||||
      {:ecto_sql, "~> 3.4"},
 | 
					      {:ecto_sql, "~> 3.4"},
 | 
				
			||||||
 | 
					      {:ex_prompt, "~> 0.1.5"},
 | 
				
			||||||
      {:linguist, "0.3.1"},
 | 
					      {:linguist, "0.3.1"},
 | 
				
			||||||
      {:postgrex, ">= 0.0.0"},
 | 
					      {:postgrex, ">= 0.0.0"},
 | 
				
			||||||
      {:phoenix_html, "~> 2.11"},
 | 
					      {:phoenix_html, "~> 2.11"},
 | 
				
			||||||
      {:phoenix_live_reload, "~> 1.2", only: :dev},
 | 
					      {:phoenix_live_reload, "~> 1.2", only: :dev},
 | 
				
			||||||
      {:phoenix_live_dashboard, "~> 0.2.0"},
 | 
					      {:phoenix_live_dashboard, "~> 0.2.0"},
 | 
				
			||||||
 | 
					      {:phoenix_pubsub, "~> 2.0"},
 | 
				
			||||||
      {:pow, "~> 1.0.20"},
 | 
					      {:pow, "~> 1.0.20"},
 | 
				
			||||||
      {:telemetry_metrics, "~> 0.4"},
 | 
					      {:telemetry_metrics, "~> 0.4"},
 | 
				
			||||||
      {:telemetry_poller, "~> 0.4"},
 | 
					      {:telemetry_poller, "~> 0.4"},
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
defmodule Auth.Repo.Migrations.CreateUsers do
 | 
					defmodule Core.Repo.Migrations.CreateUsers do
 | 
				
			||||||
  use Ecto.Migration
 | 
					  use Ecto.Migration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def change do
 | 
					  def change do
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
defmodule Auth.Repo.Migrations.AddPowEmailConfirmationToUsers do
 | 
					defmodule Core.Repo.Migrations.AddPowEmailConfirmationToUsers do
 | 
				
			||||||
  use Ecto.Migration
 | 
					  use Ecto.Migration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def change do
 | 
					  def change do
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
defmodule Auth.Repo.Migrations.AddRolesToUsers do
 | 
					defmodule Core.Repo.Migrations.AddRolesToUsers do
 | 
				
			||||||
  use Ecto.Migration
 | 
					  use Ecto.Migration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def change do
 | 
					  def change do
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
defmodule Auth.Repo.Migrations.AddNicenameToUsers do
 | 
					defmodule Core.Repo.Migrations.AddNicenameToUsers do
 | 
				
			||||||
  use Ecto.Migration
 | 
					  use Ecto.Migration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def change do
 | 
					  def change do
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
defmodule Auth.Repo.Migrations.AddUrlToUsers do
 | 
					defmodule Core.Repo.Migrations.AddUrlToUsers do
 | 
				
			||||||
  use Ecto.Migration
 | 
					  use Ecto.Migration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def change do
 | 
					  def change do
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
defmodule Auth.RolesTest do
 | 
					defmodule Auth.RolesTest do
 | 
				
			||||||
  use Auth.DataCase
 | 
					  use Core.DataCase
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  import Auth.Roles
 | 
					  import Auth.Roles
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
defmodule Auth.UserTest do
 | 
					defmodule Auth.UserTest do
 | 
				
			||||||
  use Auth.DataCase
 | 
					  use Core.DataCase
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  import Auth.User
 | 
					  import Auth.User
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										25
									
								
								apps/core/test/auth_web/helpers_test.exs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								apps/core/test/auth_web/helpers_test.exs
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -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
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
defmodule AuthWeb.Plugs.RequireAdminTest do
 | 
					defmodule AuthWeb.Plugs.RequireAdminTest do
 | 
				
			||||||
  use AuthWeb.ConnCase
 | 
					  use CoreWeb.ConnCase
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  alias AuthWeb.Plugs.RequireAdmin
 | 
					  alias AuthWeb.Plugs.RequireAdmin
 | 
				
			||||||
  alias Auth.User
 | 
					  alias Auth.User
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
defmodule AuthWeb.ErrorViewTest do
 | 
					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
 | 
					  # Bring render/3 and render_to_string/3 for testing custom views
 | 
				
			||||||
  import Phoenix.View
 | 
					  import Phoenix.View
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
defmodule AuthWeb.LayoutViewTest do
 | 
					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
 | 
					  # When testing helpers, you may want to import Phoenix.HTML and
 | 
				
			||||||
  # use functions such as safe_to_string() to convert the helper
 | 
					  # use functions such as safe_to_string() to convert the helper
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,3 @@
 | 
				
			||||||
defmodule AuthWeb.PageViewTest do
 | 
					defmodule AuthWeb.PageViewTest do
 | 
				
			||||||
  use AuthWeb.ConnCase, async: true
 | 
					  use CoreWeb.ConnCase, async: true
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,7 @@ use Mix.Config
 | 
				
			||||||
[
 | 
					[
 | 
				
			||||||
  {:admin, Admin, false},
 | 
					  {:admin, Admin, false},
 | 
				
			||||||
  {:app, AppWeb, true},
 | 
					  {:app, AppWeb, true},
 | 
				
			||||||
  {:auth_web, AuthWeb, false},
 | 
					  {:core, AuthWeb, false},
 | 
				
			||||||
  {:content, Content, false},
 | 
					  {:content, Content, false},
 | 
				
			||||||
  {:core, CoreWeb, false},
 | 
					  {:core, CoreWeb, false},
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
| 
						 | 
					@ -12,19 +12,17 @@ use Mix.Config
 | 
				
			||||||
  error_view = Module.concat(module, "ErrorView")
 | 
					  error_view = Module.concat(module, "ErrorView")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  config otp_app, endpoint,
 | 
					  config otp_app, endpoint,
 | 
				
			||||||
  url: [host: "localhost"],
 | 
					    url: [host: "localhost"],
 | 
				
			||||||
  secret_key_base: "r2eN53mJ9RmlGz9ZQ7xf43P3Or59aaO9rdf5D3hRcsuiH44pGW9kPGfl5mt9N1Gi",
 | 
					    secret_key_base: "r2eN53mJ9RmlGz9ZQ7xf43P3Or59aaO9rdf5D3hRcsuiH44pGW9kPGfl5mt9N1Gi",
 | 
				
			||||||
  render_errors: [view: error_view, accepts: ~w(html json), layout: false],
 | 
					    render_errors: [view: error_view, accepts: ~w(html json), layout: false],
 | 
				
			||||||
  pubsub_server: App.PubSub,
 | 
					    pubsub_server: App.PubSub,
 | 
				
			||||||
  live_view: [signing_salt: "g5ltUbnQ"],
 | 
					    live_view: [signing_salt: "g5ltUbnQ"],
 | 
				
			||||||
  server: start_server
 | 
					    server: start_server
 | 
				
			||||||
end)
 | 
					end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[
 | 
					[
 | 
				
			||||||
  {:admin, Admin.Repo},
 | 
					  {:admin, Admin.Repo},
 | 
				
			||||||
  {:app, App.Repo},
 | 
					  {:app, App.Repo},
 | 
				
			||||||
  {:auth, Auth.Repo},
 | 
					 | 
				
			||||||
  {:auth_web, Auth.Repo, :auth},
 | 
					 | 
				
			||||||
  {:content, Content.Repo},
 | 
					  {:content, Content.Repo},
 | 
				
			||||||
  {:core, Core.Repo},
 | 
					  {:core, Core.Repo},
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
| 
						 | 
					@ -40,9 +38,9 @@ end)
 | 
				
			||||||
      generators: [context_app: context_app]
 | 
					      generators: [context_app: context_app]
 | 
				
			||||||
end)
 | 
					end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
config :auth_web, :pow,
 | 
					config :core, :pow,
 | 
				
			||||||
  user: Auth.User,
 | 
					  user: Auth.User,
 | 
				
			||||||
  repo: Auth.Repo,
 | 
					  repo: Core.Repo,
 | 
				
			||||||
  extensions: [PowEmailConfirmation, PowPersistentSession, PowResetPassword],
 | 
					  extensions: [PowEmailConfirmation, PowPersistentSession, PowResetPassword],
 | 
				
			||||||
  controller_callbacks: Pow.Extension.Phoenix.ControllerCallbacks,
 | 
					  controller_callbacks: Pow.Extension.Phoenix.ControllerCallbacks,
 | 
				
			||||||
  mailer_backend: AuthWeb.Pow.Mailer,
 | 
					  mailer_backend: AuthWeb.Pow.Mailer,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,7 +9,7 @@ use Mix.Config
 | 
				
			||||||
[
 | 
					[
 | 
				
			||||||
  {:admin, Admin},
 | 
					  {:admin, Admin},
 | 
				
			||||||
  {:app, AppWeb},
 | 
					  {:app, AppWeb},
 | 
				
			||||||
  {:auth_web, AuthWeb},
 | 
					  {:core, AuthWeb},
 | 
				
			||||||
  {:content, Content},
 | 
					  {:content, Content},
 | 
				
			||||||
  {:core, CoreWeb},
 | 
					  {:core, CoreWeb},
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
| 
						 | 
					@ -43,7 +43,6 @@ end)
 | 
				
			||||||
[
 | 
					[
 | 
				
			||||||
  {:admin, Admin.Repo},
 | 
					  {:admin, Admin.Repo},
 | 
				
			||||||
  {:app, App.Repo},
 | 
					  {:app, App.Repo},
 | 
				
			||||||
  {:auth, Auth.Repo},
 | 
					 | 
				
			||||||
  {:content, Content.Repo},
 | 
					  {:content, Content.Repo},
 | 
				
			||||||
  {:core, Core.Repo}
 | 
					  {:core, Core.Repo}
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,10 +17,6 @@ config :admin, Admin.Endpoint,
 | 
				
			||||||
  url: [host: "example.com", port: 80],
 | 
					  url: [host: "example.com", port: 80],
 | 
				
			||||||
  cache_static_manifest: "priv/static/cache_manifest.json"
 | 
					  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,
 | 
					config :content, Content.Endpoint,
 | 
				
			||||||
  url: [host: "example.com", port: 80],
 | 
					  url: [host: "example.com", port: 80],
 | 
				
			||||||
  cache_static_manifest: "priv/static/cache_manifest.json"
 | 
					  cache_static_manifest: "priv/static/cache_manifest.json"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,7 @@ use Mix.Config
 | 
				
			||||||
[
 | 
					[
 | 
				
			||||||
  {:admin, Admin},
 | 
					  {:admin, Admin},
 | 
				
			||||||
  {:app, AppWeb},
 | 
					  {:app, AppWeb},
 | 
				
			||||||
  {:auth_web, AuthWeb},
 | 
					  {:core, AuthWeb},
 | 
				
			||||||
  {:content, Content},
 | 
					  {:content, Content},
 | 
				
			||||||
  {:core, CoreWeb},
 | 
					  {:core, CoreWeb},
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
| 
						 | 
					@ -24,7 +24,6 @@ end)
 | 
				
			||||||
[
 | 
					[
 | 
				
			||||||
  {:admin, Admin.Repo},
 | 
					  {:admin, Admin.Repo},
 | 
				
			||||||
  {:app, App.Repo},
 | 
					  {:app, App.Repo},
 | 
				
			||||||
  {:auth, Auth.Repo},
 | 
					 | 
				
			||||||
  {:content, Content.Repo},
 | 
					  {:content, Content.Repo},
 | 
				
			||||||
  {:core, Core.Repo}
 | 
					  {:core, Core.Repo}
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue