diff --git a/CHANGELOG.md b/CHANGELOG.md index 132ec24..85fa304 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ * Plug and Phoenix controller now handles `:session_params` rather than `:state` for any params that needs to be stored temporarily during authorization * Added handling of `oauth_token_secret` to OAuth strategies * Support any `:plug` version below `2.0.0` +* Fixed bug in `mix pow_assent.ecto.gen.migration` task where `--binary-id` flag didn't generate correct migration +* Support `:pow` version `1.0.5` ## v0.2.2 (2019-03-25) diff --git a/README.md b/README.md index b5a8185..66e2f7a 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,8 @@ Run `mix deps.get` to install it. It's required to set up [Pow](https://github.com/danschultzer/pow#getting-started-phoenix) first. You can [run these quick setup](guides/POW.md) instructions if Pow hasn't already been set up. +If your user schema uses binary id, then run the PowAssent mix task(s) with the `--binary-id` flag. + ### Set up PowAssent Install the necessary files: diff --git a/lib/mix/tasks/ecto/pow_assent.ecto.gen.migrations.ex b/lib/mix/tasks/ecto/pow_assent.ecto.gen.migration.ex similarity index 100% rename from lib/mix/tasks/ecto/pow_assent.ecto.gen.migrations.ex rename to lib/mix/tasks/ecto/pow_assent.ecto.gen.migration.ex diff --git a/lib/pow_assent/phoenix/controllers/authorization_controller.ex b/lib/pow_assent/phoenix/controllers/authorization_controller.ex index 554446d..eb4ff53 100644 --- a/lib/pow_assent/phoenix/controllers/authorization_controller.ex +++ b/lib/pow_assent/phoenix/controllers/authorization_controller.ex @@ -98,7 +98,7 @@ defmodule PowAssent.Phoenix.AuthorizationController do conn {:ok, _user, conn} -> conn - |> put_flash(:info, messages(conn).user_has_been_created(conn)) + |> put_flash(:info, extension_messages(conn).user_has_been_created(conn)) |> redirect(to: routes(conn).after_registration_path(conn)) end end @@ -108,13 +108,13 @@ defmodule PowAssent.Phoenix.AuthorizationController do conn {:ok, conn} -> conn - |> put_flash(:info, messages(conn).signed_in(conn)) + |> put_flash(:info, extension_messages(conn).signed_in(conn)) |> redirect(to: routes(conn).after_sign_in_path(conn)) end end def respond_callback({:error, {:bound_to_different_user, _changeset}, conn}) do conn - |> put_flash(:error, messages(conn).account_already_bound_to_other_user(conn)) + |> put_flash(:error, extension_messages(conn).account_already_bound_to_other_user(conn)) |> redirect(to: routes(conn).session_path(conn, :new)) end def respond_callback({:error, {:invalid_user_id_field, _changeset}, %{params: %{"provider" => provider}, private: %{pow_assent_params: params}} = conn}) do @@ -126,7 +126,7 @@ defmodule PowAssent.Phoenix.AuthorizationController do do: respond_callback({:error, conn}) def respond_callback({:error, conn}) do conn - |> put_flash(:error, messages(conn).could_not_sign_in(conn)) + |> put_flash(:error, extension_messages(conn).could_not_sign_in(conn)) |> redirect(to: routes(conn).session_path(conn, :new)) end @@ -145,12 +145,12 @@ defmodule PowAssent.Phoenix.AuthorizationController do @spec respond_delete({:ok, map(), Conn.t()}) :: Conn.t() def respond_delete({:ok, _deleted, conn}) do conn - |> put_flash(:info, messages(conn).authentication_has_been_removed(conn)) + |> put_flash(:info, extension_messages(conn).authentication_has_been_removed(conn)) |> redirect(to: after_delete_path(conn)) end def respond_delete({:error, {:no_password, _changeset}, conn}) do conn - |> put_flash(:error, messages(conn).identity_cannot_be_removed_missing_user_password(conn)) + |> put_flash(:error, extension_messages(conn).identity_cannot_be_removed_missing_user_password(conn)) |> redirect(to: after_delete_path(conn)) end diff --git a/lib/pow_assent/phoenix/controllers/registration_controller.ex b/lib/pow_assent/phoenix/controllers/registration_controller.ex index 9e2ffd8..b7245e2 100644 --- a/lib/pow_assent/phoenix/controllers/registration_controller.ex +++ b/lib/pow_assent/phoenix/controllers/registration_controller.ex @@ -36,13 +36,13 @@ defmodule PowAssent.Phoenix.RegistrationController do conn {:ok, _user, conn} -> conn - |> put_flash(:info, messages(conn).user_has_been_created(conn)) + |> put_flash(:info, extension_messages(conn).user_has_been_created(conn)) |> redirect(to: routes(conn).after_registration_path(conn)) end end def respond_create({:error, {:bound_to_different_user, _changeset}, conn}) do conn - |> put_flash(:error, messages(conn).account_already_bound_to_other_user(conn)) + |> put_flash(:error, extension_messages(conn).account_already_bound_to_other_user(conn)) |> redirect(to: routes(conn).registration_path(conn, :new)) end def respond_create({:error, {:invalid_user_id_field, changeset}, conn}), @@ -64,7 +64,7 @@ defmodule PowAssent.Phoenix.RegistrationController do _ -> conn - |> put_flash(:error, messages(conn).invalid_request(conn)) + |> put_flash(:error, extension_messages(conn).invalid_request(conn)) |> redirect(to: routes(conn).after_sign_out_path(conn)) |> halt() end diff --git a/lib/pow_assent/phoenix/views/view_helpers.ex b/lib/pow_assent/phoenix/views/view_helpers.ex index 88f9b45..e34ab64 100644 --- a/lib/pow_assent/phoenix/views/view_helpers.ex +++ b/lib/pow_assent/phoenix/views/view_helpers.ex @@ -39,14 +39,14 @@ defmodule PowAssent.Phoenix.ViewHelpers do defp oauth_signin_link(conn, provider), do: do_oauth_signin_link(conn, provider) defp do_oauth_signin_link(conn, provider, query_params \\[]) do - msg = AuthorizationController.messages(conn).login_with_provider(%{conn | params: %{"provider" => provider}}) + msg = AuthorizationController.extension_messages(conn).login_with_provider(%{conn | params: %{"provider" => provider}}) path = AuthorizationController.routes(conn).path_for(conn, AuthorizationController, :new, [provider], query_params) Link.link(msg, to: path) end defp oauth_remove_link(conn, provider) do - msg = AuthorizationController.messages(conn).remove_provider_authentication(%{conn | params: %{"provider" => provider}}) + msg = AuthorizationController.extension_messages(conn).remove_provider_authentication(%{conn | params: %{"provider" => provider}}) path = AuthorizationController.routes(conn).path_for(conn, AuthorizationController, :delete, [provider]) Link.link(msg, to: path, method: :delete) diff --git a/mix.exs b/mix.exs index 5362825..e760088 100644 --- a/mix.exs +++ b/mix.exs @@ -33,7 +33,7 @@ defmodule PowAssent.MixProject do defp deps do [ - {:pow, "~> 1.0.4"}, + {:pow, "~> 1.0.5"}, {:oauther, "~> 1.1"}, diff --git a/mix.lock b/mix.lock index b79f192..ab9e02a 100644 --- a/mix.lock +++ b/mix.lock @@ -33,7 +33,7 @@ "plug_cowboy": {:hex, :plug_cowboy, "2.0.2", "6055f16868cc4882b24b6e1d63d2bada94fb4978413377a3b32ac16c18dffba2", [:mix], [{:cowboy, "~> 2.5", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm"}, "postgrex": {:hex, :postgrex, "0.14.1", "63247d4a5ad6b9de57a0bac5d807e1c32d41e39c04b8a4156a26c63bcd8a2e49", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"}, - "pow": {:hex, :pow, "1.0.4", "8186c3eca543b5c38511c3c684e8eec951a024a324cc7c2b07e712df8cb8c64b", [:mix], [{:ecto, "~> 2.2 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.3.0 or ~> 1.4.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, ">= 2.0.0 and <= 3.0.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:plug, ">= 1.5.0 and < 1.8.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm"}, + "pow": {:hex, :pow, "1.0.5", "1f64dc1979e6ff83e76f3354968374695f7bb9826ccb2360b6b17ee88a7dd217", [:mix], [{:ecto, "~> 2.2 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.3.0 or ~> 1.4.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, ">= 2.0.0 and <= 3.0.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:plug, ">= 1.5.0 and < 2.0.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm"}, "ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.4", "f0eafff810d2041e93f915ef59899c923f4568f4585904d010387ed74988e77b", [:make, :mix, :rebar3], [], "hexpm"}, "telemetry": {:hex, :telemetry, "0.3.0", "099a7f3ce31e4780f971b4630a3c22ec66d22208bc090fe33a2a3a6a67754a73", [:rebar3], [], "hexpm"}, diff --git a/test/mix/tasks/ecto/pow_assent.ecto.gen.migrations_test.exs b/test/mix/tasks/ecto/pow_assent.ecto.gen.migration_test.exs similarity index 91% rename from test/mix/tasks/ecto/pow_assent.ecto.gen.migrations_test.exs rename to test/mix/tasks/ecto/pow_assent.ecto.gen.migration_test.exs index 6dcba3e..b99b72e 100644 --- a/test/mix/tasks/ecto/pow_assent.ecto.gen.migrations_test.exs +++ b/test/mix/tasks/ecto/pow_assent.ecto.gen.migration_test.exs @@ -30,7 +30,7 @@ defmodule Mix.Tasks.PowAssent.Ecto.Gen.MigrationTest do assert file =~ "defmodule #{inspect(Repo)}.Migrations.CreateUserIdentities do" assert file =~ "create table(:user_identities)" - assert file =~ "add :user_id, references(\"users\"), on_delete: :nothing" + assert file =~ "add :user_id, references(\"users\", on_delete: :nothing)" assert file =~ "timestamps(updated_at: false)" end) end @@ -58,7 +58,7 @@ defmodule Mix.Tasks.PowAssent.Ecto.Gen.MigrationTest do assert file =~ "create table(:user_identities, primary_key: false)" assert file =~ "add :id, :binary_id, primary_key: true" - assert file =~ "add :user_id, references(\"users\"), on_delete: :nothing, type: :binary_id" + assert file =~ "add :user_id, references(\"users\", on_delete: :nothing, type: :binary_id)" end) end end