Skip to content

Commit 03c9d33

Browse files
committed
Update changelog
1 parent 4281316 commit 03c9d33

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v1.0.38 (TBA)
4+
5+
### Bug fixes
6+
7+
* [`Pow.Ecto.Schema.Changeset`] Fixed issue with schemas having a `:data` field not being handled correctly in changeset functions
8+
39
## v1.0.37 (2024-03-03)
410

511
### Bug fixes

lib/pow/ecto/schema/changeset.ex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ defmodule Pow.Ecto.Schema.Changeset do
111111

112112
do_confirm_password_changeset(user_or_changeset, params)
113113
end
114+
114115
def confirm_password_changeset(user_or_changeset, %{"confirm_password" => password_confirmation} = params, _config) do
115116
params =
116117
params
@@ -119,6 +120,7 @@ defmodule Pow.Ecto.Schema.Changeset do
119120

120121
convert_confirm_password_param(user_or_changeset, params)
121122
end
123+
122124
def confirm_password_changeset(user_or_changeset, params, _config),
123125
do: do_confirm_password_changeset(user_or_changeset, params)
124126

@@ -164,6 +166,7 @@ defmodule Pow.Ecto.Schema.Changeset do
164166
defp reset_current_password_field(%Changeset{data: user} = changeset) do
165167
%{changeset | data: reset_current_password_field(user)}
166168
end
169+
167170
defp reset_current_password_field(user) do
168171
%{user | current_password: nil}
169172
end
@@ -183,6 +186,7 @@ defmodule Pow.Ecto.Schema.Changeset do
183186

184187
defp maybe_validate_current_password(%Changeset{data: %{password_hash: nil}} = changeset, _config),
185188
do: changeset
189+
186190
defp maybe_validate_current_password(changeset, config) do
187191
changeset = Changeset.validate_required(changeset, [:current_password])
188192

@@ -222,13 +226,15 @@ defmodule Pow.Ecto.Schema.Changeset do
222226

223227
false
224228
end
229+
225230
def verify_password(%{password_hash: password_hash}, password, config) do
226231
apply_password_verify_function(config, [password, password_hash])
227232
end
228233

229234
defp maybe_require_password(%Changeset{data: %{password_hash: nil}} = changeset) do
230235
Changeset.validate_required(changeset, [:password])
231236
end
237+
232238
defp maybe_require_password(changeset), do: changeset
233239

234240
defp maybe_validate_password(changeset, config) do
@@ -250,11 +256,13 @@ defmodule Pow.Ecto.Schema.Changeset do
250256
defp maybe_put_password_hash(%Changeset{valid?: true, changes: %{password: password}} = changeset, config) do
251257
Changeset.put_change(changeset, :password_hash, hash_password(password, config))
252258
end
259+
253260
defp maybe_put_password_hash(changeset, _config), do: changeset
254261

255262
defp maybe_validate_password_hash(%Changeset{valid?: true} = changeset) do
256263
Changeset.validate_required(changeset, [:password_hash])
257264
end
265+
258266
defp maybe_validate_password_hash(changeset), do: changeset
259267

260268
defp hash_password(password, config) do
@@ -413,6 +421,7 @@ defmodule Pow.Ecto.Schema.Changeset do
413421
_label, error -> {:halt, error}
414422
end)
415423
end
424+
416425
defp validate_dns_labels({:error, error}), do: {:error, error}
417426

418427
defp validate_dns_label(label) do

test/pow/ecto/schema/changeset_test.exs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,12 @@ defmodule Pow.Ecto.Schema.ChangesetTest do
424424
use Ecto.Schema
425425
use Pow.Ecto.Schema
426426

427+
@ecto_derive_inspect_for_redacted_fields false
428+
427429
schema "users" do
428430
pow_user_fields()
429431

430-
field(:data, :string)
432+
field :data, :string
431433
end
432434
end
433435

@@ -436,7 +438,6 @@ defmodule Pow.Ecto.Schema.ChangesetTest do
436438

437439
test "pow_current_password_changeset/2" do
438440
password_hash = Password.pbkdf2_hash(@password)
439-
440441
user = %UserDataAttribute{password_hash: password_hash}
441442

442443
assert UserDataAttribute.changeset(user, %{})

0 commit comments

Comments
 (0)