Skip to content

Commit bdad40f

Browse files
committed
Remove deprecations and up requirements
New minimum: - Elixir 1.7 - Ecto 3.0 - Phoenix 1.4
1 parent ba3115c commit bdad40f

File tree

30 files changed

+51
-502
lines changed

30 files changed

+51
-502
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ services:
66
jobs:
77
include:
88
- stage: test
9-
elixir: 1.6
9+
elixir: 1.7
1010
otp_release: 20.0
1111
script: &test_scripts
1212
- mix test
13-
- MIX_ENV=test mix credo --ignore design.tagtodo
13+
- MIX_ENV=test mix credo
1414
- stage: test
1515
elixir: 1.8
1616
script: *test_scripts

CHANGELOG.md

Lines changed: 21 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,29 @@
11
# Changelog
22

3-
## v1.0.14 (TBA)
4-
5-
* Changed minmum password length to 8 (OWASP/NIST recommendations)
6-
* Fixed bug where `Pow.Store.CredentialsCache` wasn't used due to how `Pow.Store.Base` macro worked
7-
* `Pow.Plug.Session` now stores a keyword list with metadata for the session rather than just the timestamp
8-
9-
## v1.0.13 (2019-08-25)
10-
11-
* Updated `PowEmailConfirmation.Ecto.Schema.changeset/3` so;
12-
* when `:email` is identical to `:unconfirmed_email` it won't generate new `:email_confirmation_token`
13-
* when `:email` is identical to the persisted `:email` value both `:email_confirmation_token` and `:unconfirmed_email` will be set to `nil`
14-
* when there is no `:email` value in the params nothing happens
15-
* Updated `PowEmailConfirmation.Ecto.Schema.confirm_email_changeset/1` so now `:email_confirmation_token` is set to `nil`
16-
* Updated `Pow.Ecto.Schema.Changeset.user_id_field_changeset/3` so the e-mail validator now accepts unicode e-mails
17-
* Added `PowEmailConfirmation.Ecto.Context.current_email_unconfirmed?/2` and `PowEmailConfirmation.Plug.pending_email_change?/1`
18-
* Added `:email_validator` configuration option to `Pow.Ecto.Schema.Changeset`
19-
* Added `Pow.Ecto.Schema.Changeset.validate_email/1`
20-
* Fixed bug in `PowEmailConfirmation.Phoenix.ControllerCallbacks.send_confirmation_email/2` where the confirmation e-mail wasn't send to the updated e-mail address
21-
22-
## v1.0.12 (2019-08-16)
23-
24-
* Added API integration guide
25-
* Added `:reset_password_token_store` configuration setting
26-
* To prevent timing attacks, `Pow.Ecto.Context.authenticate/2` now verifies password on a blank user struct when no user can be found for the provided user id, but will always return nil. The blank user struct has a nil `:password_hash` value. The struct will be passed along with a blank password to the `verify_password/2` method in the user schema module.
27-
* To prevent timing attacks, when `Pow.Ecto.Schema.Changeset.verify_password/3` receives a struct with a nil `:password_hash` value, it'll hash a blank password, but always return false.
28-
* To prevent timing attacks, the UUID is always generated in `PowResetPassword.Plug.create_reset_token/2` whether the user exists or not.
29-
* `PowPersistentSession.Plug.Base` now accepts `:persistent_session_ttl` which will pass the TTL to the cache backend and used for the max age of the sesion cookie in `PowPersistentSession.Plug.Cookie`
30-
* Deprecated `:persistent_session_cookie_max_age` configuration setting
31-
* `Pow.Store.Backend.MnesiaCache` can now auto join clusters
32-
* `Pow.Store.Backend.MnesiaCache.Unsplit` module added for self-healing after network split
33-
* Removed `:nodes` config option for `Pow.Store.Backend.MnesiaCache`
34-
35-
## v1.0.11 (2019-06-13)
36-
37-
* Fixed bug in router filters with Phoenix 1.4.7
38-
39-
## v1.0.10 (2019-06-09)
40-
41-
* Prevent browser cache of `Pow.Phoenix.SessionController.new/2`, `Pow.Phoenix.RegistrationController.new/2` and `PowInvitation.Phoenix.InvitationController.edit/2` by setting "Cache-Control" header unless it already has been customized
42-
* All links in docs generated with `mix docs` and on [hexdocs.pm](http://hexdocs.pm/pow/) now works
43-
* Generated docs now uses lower case file name except for `README`, `CONTRIBUTING` and `CHANGELOG`
44-
* Removed duplicate call for `Pow.Plug.Session.delete/2` in `Pow.Plug.Sesssion.create/3`
45-
46-
## v1.0.9 (2019-06-04)
47-
48-
### Changes
49-
50-
* `Pow.Phoenix.Router` will now only add specific routes if there is no matching route already defined
51-
* Added `Pow.Plug.get_plug/1` and instead of `:mod`, `:plug` is used in config
52-
* `Pow.Ecto.Context.authenticate/2` now returns nil if user id or password is nil
53-
54-
### Bug fixes
55-
56-
* Fixed bug with exception raised in `Pow.Ecto.Schema.normalize_user_id_field_value/1` when calling `Pow.Ecto.Context.get_by/2` with a non binary user id
57-
* Fixed bug with exception raised in `Pow.Ecto.Schema.normalize_user_id_field_value/1` when calling `Pow.Ecto.Context.authenticate/2` with a non binary user id
58-
59-
### Deprecations
60-
61-
* Deprecated `Pow.Plug.get_mod/1`
62-
* Removed call to `Pow.Ecto.Context.repo/1`
63-
64-
## v1.0.8 (2019-05-24)
65-
66-
### Changes
67-
68-
* Added support for layout in mails with `Pow.Phoenix.Mailer.Mail` by setting `conn.private[:pow_mailer_layout]` same way as the Phoenix layout with `conn.private[:phoenix_layout]`
69-
* Added `:prefix` repo opts support to use in multitenant apps
70-
* Removed `@changeset.data.__struct__.pow_user_id_field()` in template in favor of using `Pow.Ecto.Schema.user_id_field/1`
71-
72-
### Bug fixes
73-
74-
* Fixed bug in `Pow.Ecto.Schema.Changeset.current_password_changeset/3` where an exception would be thrown if the virtual `:current_password` field of the user struct was set and either the `:current_password` change was blank or identical
75-
76-
### Deprecations
77-
78-
* Deprecated `Mix.Pow.Ecto.Migration.create_migration_files/3` and moved it to `Mix.Pow.Ecto.Migration.create_migration_file/3`
79-
* Deprecated `Pow.Ecto.Context.repo/1` and moved it to `Pow.Config.repo!/1`
80-
* Deprecated `Pow.Ecto.Context.user_schema_mod/1` and moved it to `Pow.Config.user!/1`
81-
82-
## v1.0.7 (2019-05-01)
83-
84-
* Fixed bug with Phoenix 1.4.4 scoped routes
85-
86-
## v1.0.6 (2019-04-19)
87-
88-
* Fixed bug where custom layout setting raised exception in `Pow.Phoenix.ViewHelpers.layout/1`
89-
* Prevent users from changing their email to one already taken when the PowEmailConfirmation extension has been enabled
90-
91-
## v1.0.5 (2019-04-09)
92-
93-
* Added `extension_messages/1` to extension controllers and callbacks
94-
* Improved feedback for when no templates are generated for an extension with `mix pow.extension.phoenix.gen.templates` and `mix pow.extension.phoenix.mailer.gen.templates` tasks
95-
* Error flash is no longer overridden in `Pow.Phoenix.PlugErrorHandler` if the error message is nil
96-
* Fixed bug in the migration generator where `references/2` wasn't called with options
97-
* Support any `:plug` version below `2.0.0`
98-
* Deprecated `Pow.Extension.Ecto.Context.Base`
99-
100-
## v1.0.4 (2019-03-13)
101-
102-
* Added `PowInvitation` to the `mix pow.extension.phoenix.gen.templates` and `mix pow.extension.phoenix.mailer.gen.templates` tasks
103-
* Fixed issue in umbrella projects where extensions wasn't found in environment configuration
104-
* Fixed so `:namespace` environment config can be used as web app module name
105-
* Shell instructions will only be printed if the configuration is missing
106-
* Now requires that `:ecto` or `:phoenix` are included in the dependency list for the app to run respective mix tasks
107-
* Deprecated `Mix.Pow.context_app/0`
108-
* Deprecated `Mix.Pow.ensure_dep!/3`
109-
* Deprecated `Mix.Pow.context_base/1`
110-
111-
## v1.0.3 (2019-03-09)
3+
## v1.1.0 (TBA)
1124

1135
### Changes
1146

115-
* Added `PowInvitation` extension
116-
* Added support in `Pow.Ecto.Schema` for Ecto associations fields
117-
* Added support for adding custom methods with `Pow.Extension.Ecto.Schema` through `__using__/1` macro in extension ecto schema module
118-
* Help information raised with invalid schema arguments for `pow.install`, `pow.ecto.install`, `pow.ecto.gen.migration`, and `pow.ecto.gen.schema` mix tasks
119-
* `PowEmailConfirmation` now redirects unconfirmed users to `after_registration_path/1` or `after_sign_in_path/1` rather than `pow_session_path(conn, :new)`
120-
121-
### Bug fixes
122-
123-
* Correct shell instructions for `mix pow.install` task with custom schema
124-
* Fixed bug in `Pow.Extension.Phoenix.Router.Base` and `Pow.Extension.Phoenix.Messages` where the full extension name wasn't used to namespace methods
7+
- Requires Elixir 1.7 or higher
8+
- Requires Ecto 3.0 or higher
9+
- Requires Phoenix 1.4.7 or higher
12510

12611
### Deprecations
12712

128-
* Deprecated `Pow.Extension.Config.underscore_extension/1`
129-
* Deprecated `PowResetPassword.Ecto.Context.password_changeset/2`
130-
* Deprecated `Pow.Ecto.Schema.filter_new_fields/2`
131-
* Deprecated `:messages_backend_fallback` setting for extension controllers
132-
* Removed deprecated macro `router_helpers/1` in `Pow.Phoenix.Controller`
133-
134-
## v1.0.2 (2019-02-28)
135-
136-
* Added flash error message about e-mail confirmation for when user changes e-mail with PowEmailConfirmation enabled
137-
* Added `new_password_changeset/3` and `confirm_password_changeset/3` to `Pow.Ecto.Schema.Changeset`
138-
* Redis cache store backend guide
139-
* Correct shell instructions for `mix pow.phoenix.gen.templates` task
140-
* Only load environment config in `Pow.Config.get/3` when no key is set in the provided config
141-
* Fixed issue in `Pow.Store.Backend.MnesiaCache.keys/1` and `Pow.Store.Backend.EtsCache.keys/1` so they now return keys without namespace
142-
* `Pow.Store.Backend.MnesiaCache.put/3` now raises an error if TTL is not provided
143-
144-
### Breaking changes
145-
146-
* `PowResetPassword.Plug.reset_password_token/1` has been removed
147-
148-
## v1.0.1 (2019-01-27)
149-
150-
* `pow.extension.ecto.gen.migrations` mix task will output warning when a migration file won't be generated for any particular extension
151-
* Leading and trailing whitespace is removed from the user id field value (in addition to forced lower case)
152-
* An exception is raised when `pow_routes/0` or `pow_extension_routes/0` are used inside router scopes with aliases
153-
* Mail view templates assigns now has `[user: user, conn: conn]` along with the template specific assigns
154-
* Mail view subject methods now gets the same assigns passed as mail view template assigns instead of only `[conn: conn]`
155-
* Added `pow_registration_routes/0`, `pow_session_routes/0` and `pow_scope/1` macros to the router module
156-
* Added guide on how to disable registration
157-
158-
## v1.0.0 (2018-11-18)
159-
160-
* Phoenix 1.4 support
161-
* Ecto 3.0 support
13+
- Removed deprecated method `PowResetPassword.Ecto.Context.password_changeset/2`
14+
- Removed deprecated method `Pow.Extension.Config.underscore_extension/1`
15+
- Removed deprecated method `Mix.Pow.context_app/0`
16+
- Removed deprecated method `Mix.Pow.ensure_dep!/3`
17+
- Removed deprecated method `Mix.Pow.context_base/1`
18+
- Removed deprecated method `Mix.Pow.Ecto.Migration.create_migration_files/3`
19+
- Removed deprecated method `Pow.Ecto.Context.repo/1`
20+
- Removed deprecated method `Pow.Ecto.Context.user_schema_mod/1`
21+
- Removed deprecated method `Pow.Plug.get_mod/1`
22+
- Config fallback set with `:messages_backend_fallback` configuration option removed in `Pow.Extension.Phoenix.Controller.Base`
23+
- Removed deprecated Bootstrap support in `Pow.Phoenix.HTML.FormTemplate`
24+
- Removed deprecated module `Pow.Extension.Ecto.Context.Base`
25+
- `:mod` in the `:pow_config` private plug key no longer set in `Pow.Plug.Base`
26+
- Removed deprecated `:persistent_session_cookie_max_age` config option for `PowPersistentSession.Plug.Cookie`
27+
- Removed deprecated `:nodes` config option for `Pow.Store.Backend.MnesiaCache`
28+
- `Pow.Store.Base` macro no longer has the `Pow.Store.Backend.Base` behaviour and the methods are no longer overridable
29+
- `Pow.Plug.Session` no longer has backwards compatibility with `<= 1.0.13` session values

lib/extensions/persistent_session/plug/cookie.ex

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,8 @@ defmodule PowPersistentSession.Plug.Cookie do
174174
end
175175

176176
defp max_age(config) do
177-
# TODO: Remove by 1.1.0
178-
case Config.get(config, :persistent_session_cookie_max_age) do
179-
nil ->
180-
config
181-
|> PowPersistentSession.Plug.Base.ttl()
182-
|> Integer.floor_div(1000)
183-
184-
max_age ->
185-
IO.warn("use of `:persistent_session_cookie_max_age` config value in #{inspect unquote(__MODULE__)} is deprecated, please use `:persistent_session_ttl`")
186-
187-
max_age
188-
end
177+
config
178+
|> PowPersistentSession.Plug.Base.ttl()
179+
|> Integer.floor_div(1000)
189180
end
190181
end

lib/extensions/reset_password/ecto/context.ex

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,4 @@ defmodule PowResetPassword.Ecto.Context do
1212
|> Schema.reset_password_changeset(params)
1313
|> Context.do_update(config)
1414
end
15-
16-
# TODO: Remove by 1.1.0
17-
@deprecated "Use `PowResetPassword.Ecto.Schema.reset_password_changeset/2` instead"
18-
def password_changeset(user, params), do: Schema.reset_password_changeset(user, params)
1915
end

lib/mix/pow.ex

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,6 @@ defmodule Mix.Pow do
1616
:ok
1717
end
1818

19-
# TODO: Remove by 1.1.0
20-
@doc false
21-
@deprecated "Use `ensure_ecto!` or `ensure_phoenix!` instead"
22-
@spec ensure_dep!(binary(), atom(), OptionParser.argv()) :: :ok | no_return
23-
def ensure_dep!(task, dep, _args) do
24-
fetch_deps()
25-
|> top_level_dep_in_deps?(dep)
26-
|> case do
27-
true ->
28-
:ok
29-
30-
false ->
31-
Mix.raise("mix #{task} can only be run inside an application directory that has #{inspect dep} as dependency")
32-
end
33-
end
34-
3519
@doc """
3620
Raises an exception if application doesn't have Ecto as dependency.
3721
"""
@@ -53,15 +37,7 @@ defmodule Mix.Pow do
5337
end)
5438
end
5539

56-
# TODO: Remove by 1.1.0 and only support Elixir 1.7
57-
defp fetch_deps do
58-
System.version()
59-
|> Version.match?("~> 1.6.0")
60-
|> case do
61-
true -> apply(Dep, :loaded, [[]])
62-
false -> apply(Dep, :load_on_environment, [[]])
63-
end
64-
end
40+
defp fetch_deps, do: Dep.load_on_environment([])
6541

6642
@doc """
6743
Raises an exception if application doesn't have Phoenix as dependency.
@@ -147,36 +123,12 @@ defmodule Mix.Pow do
147123
""")
148124
end
149125

150-
# TODO: Remove by 1.1.0
151-
@doc false
152-
@deprecated "Please use `Pow.Phoenix.parse_structure/1` instead"
153-
@spec context_app :: atom() | no_return
154-
def context_app do
155-
this_app = otp_app()
156-
157-
this_app
158-
|> Application.get_env(:generators, [])
159-
|> Keyword.get(:context_app)
160-
|> case do
161-
nil -> this_app
162-
false -> Mix.raise("No context_app configured for current application")
163-
{app, _path} -> app
164-
app -> app
165-
end
166-
end
167-
168126
@doc false
169127
@spec otp_app :: atom() | no_return
170128
def otp_app do
171129
Keyword.fetch!(Mix.Project.config(), :app)
172130
end
173131

174-
# TODO: Remove by 1.1.0
175-
@doc false
176-
@deprecated "Use `app_base/1` instead"
177-
@spec context_base(atom()) :: atom()
178-
def context_base(app), do: app_base(app)
179-
180132
@doc """
181133
Fetches the context base module for the app.
182134
"""

lib/mix/pow/ecto/migration.ex

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ defmodule Mix.Pow.Ecto.Migration do
22
@moduledoc """
33
Utilities module for ecto migrations in mix tasks.
44
"""
5-
alias Mix.Generator
6-
7-
# TODO: Remove by 1.1.0
8-
@doc false
9-
@deprecated "Use `create_migration_file/3`"
10-
defdelegate create_migration_files(repo, name, content), to: __MODULE__, as: :create_migration_file
5+
alias Mix.{EctoSQL, Generator}
116

127
@doc """
138
Creates a migration file for a repo.
@@ -17,7 +12,7 @@ defmodule Mix.Pow.Ecto.Migration do
1712
base_name = "#{Macro.underscore(name)}.exs"
1813
path =
1914
repo
20-
|> source_repo_priv()
15+
|> EctoSQL.source_repo_priv()
2116
|> Path.join("migrations")
2217
|> maybe_create_directory()
2318
timestamp = timestamp(path)
@@ -68,14 +63,4 @@ defmodule Mix.Pow.Ecto.Migration do
6863

6964
defp pad(i) when i < 10, do: <<?0, ?0 + i>>
7065
defp pad(i), do: to_string(i)
71-
72-
# TODO: Remove by 1.1.0 and only use Ecto 3.0
73-
defp source_repo_priv(repo) do
74-
mod =
75-
if Pow.dependency_vsn_match?(:ecto, "< 3.0.0"),
76-
do: Mix.Ecto,
77-
else: Mix.EctoSQL
78-
79-
mod.source_repo_priv(repo)
80-
end
8166
end

lib/pow.ex

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
11
defmodule Pow do
22
@moduledoc false
3-
4-
@doc """
5-
Checks for version requirement in dependencies.
6-
"""
7-
@spec dependency_vsn_match?(atom(), binary()) :: boolean()
8-
def dependency_vsn_match?(dep, req) do
9-
case :application.get_key(dep, :vsn) do
10-
{:ok, actual} ->
11-
actual
12-
|> List.to_string()
13-
|> Version.match?(req)
14-
15-
_any ->
16-
false
17-
end
18-
end
193
end

lib/pow/ecto/context.ex

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,17 +229,9 @@ defmodule Pow.Ecto.Context do
229229
{:ok, struct}
230230
end
231231

232-
# TODO: Remove by 1.1.0
233-
@deprecated "Use `Pow.Config.repo!/1` instead"
234-
defdelegate repo(config), to: Config, as: :repo!
235-
236232
defp repo_opts(config, opts) do
237233
config
238234
|> Config.get(:repo_opts, [])
239235
|> Keyword.take(opts)
240236
end
241-
242-
# TODO: Remove by 1.1.0
243-
@deprecated "Use `Pow.Config.user!/1` instead"
244-
defdelegate user_schema_mod(config), to: Config, as: :user!
245237
end

lib/pow/ecto/schema.ex

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,6 @@ defmodule Pow.Ecto.Schema do
254254
Enum.filter(fields, &not Enum.member?(existing_fields, {elem(&1, 0), elem(&1, 1)}))
255255
end
256256

257-
# TODO: Remove by 1.1.0
258-
@deprecated "No longer public method"
259-
def filter_new_fields(fields, existing_fields), do: __filter_new_fields__(fields, existing_fields)
260-
261257
@doc false
262258
defmacro __register_fields__ do
263259
quote do

0 commit comments

Comments
 (0)