Skip to content

Commit 93239a6

Browse files
committed
Remove deprecations and up requirements
New minimum: - Elixir 1.7 - Ecto 3.0 - Phoenix 1.4
1 parent 8e5a20f commit 93239a6

File tree

42 files changed

+100
-1207
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+100
-1207
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: 50 additions & 347 deletions
Large diffs are not rendered by default.

lib/extensions/email_confirmation/ecto/context.ex

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,4 @@ defmodule PowEmailConfirmation.Ecto.Context do
3939
|> user_mod.confirm_email_changeset(params)
4040
|> Context.do_update(config)
4141
end
42-
43-
# TODO: Remove by 1.1.0
44-
@doc false
45-
@deprecated "Use confirm_email/3 instead"
46-
def confirm_email(user, config), do: confirm_email(user, %{}, config)
4742
end

lib/extensions/email_confirmation/ecto/schema.ex

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,4 @@ defmodule PowEmailConfirmation.Ecto.Schema do
172172
|> Changeset.change(changes)
173173
|> Changeset.unique_constraint(:email)
174174
end
175-
176-
# TODO: Remove by 1.1.0
177-
@deprecated "Use `confirm_email_changeset/2` instead"
178-
@doc false
179-
def confirm_email_changeset(changeset), do: confirm_email_changeset(changeset, %{})
180175
end

lib/extensions/email_confirmation/plug.ex

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,6 @@ defmodule PowEmailConfirmation.Plug do
8181
{:ok, user} -> {:ok, user, maybe_renew_conn(conn, user, config)}
8282
end
8383
end
84-
# TODO: Remove by 1.1.0
85-
def confirm_email(conn, token) when is_binary(token) do
86-
IO.warn "#{unquote(__MODULE__)}.confirm_email/2 called with token is deprecated, use `load_user_by_token/2` and `confirm_email/2` with map as second argument instead"
87-
88-
config = Plug.fetch_config(conn)
89-
90-
token
91-
|> Context.get_by_confirmation_token(config)
92-
|> maybe_confirm_email(conn, config)
93-
end
9484

9585
defp confirm_email_user(conn) do
9686
conn.assigns[:confirm_email_user]
@@ -110,15 +100,4 @@ defmodule PowEmailConfirmation.Plug do
110100

111101
Keyword.equal?(clauses1, clauses2)
112102
end
113-
114-
# TODO: Remove by 1.1.0
115-
defp maybe_confirm_email(nil, conn, _config), do: {:error, nil, conn}
116-
defp maybe_confirm_email(user, conn, config) do
117-
user
118-
|> Context.confirm_email(%{}, config)
119-
|> case do
120-
{:error, changeset} -> {:error, changeset, conn}
121-
{:ok, user} -> {:ok, user, maybe_renew_conn(conn, user, config)}
122-
end
123-
end
124103
end

lib/extensions/invitation/plug.ex

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,4 @@ defmodule PowInvitation.Plug do
9595
_any -> {:error, conn}
9696
end
9797
end
98-
99-
# TODO: Remove by 1.1.0
100-
@doc false
101-
@deprecated "Use `load_invited_user_by_token/2` instead"
102-
def invited_user_from_token(conn, token) do
103-
config = Plug.fetch_config(conn)
104-
105-
InvitationContext.get_by_invitation_token(token, config)
106-
end
107-
108-
# TODO: Remove by 1.1.0
109-
@doc false
110-
@deprecated "No longer used"
111-
def assign_invited_user(conn, user) do
112-
Conn.assign(conn, :invited_user, user)
113-
end
11498
end

lib/extensions/persistent_session/plug/cookie.ex

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,6 @@ defmodule PowPersistentSession.Plug.Cookie do
230230
user -> {token, {user, metadata}}
231231
end
232232
end
233-
# TODO: Remove by 1.1.0
234-
defp fetch_user({token, user_id}, config),
235-
do: fetch_user({token, {user_id, []}}, config)
236233

237234
defp filter_invalid!([id: _value] = clauses), do: clauses
238235
defp filter_invalid!(clauses), do: raise "Invalid get_by clauses stored: #{inspect clauses}"
@@ -287,7 +284,7 @@ defmodule PowPersistentSession.Plug.Cookie do
287284
defp update_session_metadata(conn, metadata) do
288285
case Keyword.get(metadata, :session_metadata) do
289286
nil ->
290-
fallback_session_fingerprint(conn, metadata)
287+
conn
291288

292289
session_metadata ->
293290
metadata = Map.get(conn.private, :pow_session_metadata, [])
@@ -296,22 +293,6 @@ defmodule PowPersistentSession.Plug.Cookie do
296293
end
297294
end
298295

299-
# TODO: Remove by 1.1.0
300-
defp fallback_session_fingerprint(conn, metadata) do
301-
case Keyword.get(metadata, :session_fingerprint) do
302-
nil ->
303-
conn
304-
305-
fingerprint ->
306-
metadata =
307-
conn.private
308-
|> Map.get(:pow_session_metadata, [])
309-
|> Keyword.put(:fingerprint, fingerprint)
310-
311-
Conn.put_private(conn, :pow_session_metadata, metadata)
312-
end
313-
end
314-
315296
defp gen_token(config) do
316297
uuid = UUID.generate()
317298

@@ -361,17 +342,8 @@ defmodule PowPersistentSession.Plug.Cookie do
361342
end
362343

363344
defp max_age(config) do
364-
# TODO: Remove by 1.1.0
365-
case Config.get(config, :persistent_session_cookie_max_age) do
366-
nil ->
367-
config
368-
|> PowPersistentSession.Plug.Base.ttl()
369-
|> Integer.floor_div(1000)
370-
371-
max_age ->
372-
IO.warn("use of `:persistent_session_cookie_max_age` config value in #{inspect unquote(__MODULE__)} is deprecated, please use `:persistent_session_ttl`")
373-
374-
max_age
375-
end
345+
config
346+
|> PowPersistentSession.Plug.Base.ttl()
347+
|> Integer.floor_div(1000)
376348
end
377349
end
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
defmodule PowResetPassword.Ecto.Context do
22
@moduledoc false
33
alias Pow.{Config, Ecto.Context, Operations}
4-
alias PowResetPassword.Ecto.Schema
54

65
@spec get_by_email(binary(), Config.t()) :: Context.user() | nil
76
def get_by_email(email, config), do: Operations.get_by([email: email], config)
@@ -12,8 +11,4 @@ defmodule PowResetPassword.Ecto.Context do
1211
|> user_mod.reset_password_changeset(params)
1312
|> Context.do_update(config)
1413
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)
1914
end

lib/extensions/reset_password/plug.ex

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ defmodule PowResetPassword.Plug do
2424
|> struct()
2525
end
2626

27-
# TODO: Remove by 1.1.0
28-
@doc false
29-
@deprecated "No longer used"
30-
def assign_reset_password_user(conn, user) do
31-
Conn.assign(conn, :reset_password_user, user)
32-
end
33-
3427
@doc """
3528
Finds a user for the provided params, creates a token, and stores the user
3629
for the token.
@@ -104,23 +97,6 @@ defmodule PowResetPassword.Plug do
10497
end
10598
end
10699

107-
# TODO: Remove by 1.1.0
108-
@doc false
109-
@deprecated "Use `load_user_by_token/2` instead"
110-
def user_from_token(conn, token) do
111-
{store, store_config} =
112-
conn
113-
|> Plug.fetch_config()
114-
|> store()
115-
116-
store_config
117-
|> store.get(token)
118-
|> case do
119-
:not_found -> nil
120-
user -> user
121-
end
122-
end
123-
124100
@doc """
125101
Updates the password for the user fetched in the connection.
126102

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
"""

0 commit comments

Comments
 (0)