AshAuthentication error when trying to use password hashing change in seed action
I'm trying to use this action to seed some test accounts:
This action has no
If I add
to the seed action, the error instead becomes:
create :seed do
accept [
:email,
:username,
:first_name,
:last_name,
]
argument :password, :string do
allow_nil? false
sensitive? true
end
change AshAuthentication.Strategy.Password.HashPasswordChange
end
create :seed do
accept [
:email,
:username,
:first_name,
:last_name,
]
argument :password, :string do
allow_nil? false
sensitive? true
end
change AshAuthentication.Strategy.Password.HashPasswordChange
end
:password_confirmation
field as it is just a seed action. However, if I do not include that and the password validation, I get this error:
** (Ash.Error.Framework) Framework Error
Context: resolving data on perform Lpe.User.seed
* Context: resolving data on perform Lpe.User.seed
Assumption failed: Error hashing password.
This should not be possible, please report a detailed bug at:
https://github.com/ash-project/ash/issues/new?assignees=&labels=bug%2C+needs+review&template=bug_report.md&title=
(ash_authentication 3.11.6) lib/ash_authentication/strategies/password/hash_password_change.ex:55: anonymous fn/3 in AshAuthentication.Strategy.Password.HashPasswordChange.change/3
(ash 2.10.2) lib/ash/changeset/changeset.ex:1978: anonymous fn/2 in Ash.Changeset.run_before_actions/1
(elixir 1.15.0) lib/enum.ex:4830: Enumerable.List.reduce/3
(elixir 1.15.0) lib/enum.ex:2564: Enum.reduce_while/3
(ash 2.10.2) lib/ash/changeset/changeset.ex:2063: Ash.Changeset.run_around_actions/2
(ash 2.10.2) lib/ash/changeset/changeset.ex:1735: anonymous fn/2 in Ash.Changeset.with_hooks/3
...
** (Ash.Error.Framework) Framework Error
Context: resolving data on perform Lpe.User.seed
* Context: resolving data on perform Lpe.User.seed
Assumption failed: Error hashing password.
This should not be possible, please report a detailed bug at:
https://github.com/ash-project/ash/issues/new?assignees=&labels=bug%2C+needs+review&template=bug_report.md&title=
(ash_authentication 3.11.6) lib/ash_authentication/strategies/password/hash_password_change.ex:55: anonymous fn/3 in AshAuthentication.Strategy.Password.HashPasswordChange.change/3
(ash 2.10.2) lib/ash/changeset/changeset.ex:1978: anonymous fn/2 in Ash.Changeset.run_before_actions/1
(elixir 1.15.0) lib/enum.ex:4830: Enumerable.List.reduce/3
(elixir 1.15.0) lib/enum.ex:2564: Enum.reduce_while/3
(ash 2.10.2) lib/ash/changeset/changeset.ex:2063: Ash.Changeset.run_around_actions/2
(ash 2.10.2) lib/ash/changeset/changeset.ex:1735: anonymous fn/2 in Ash.Changeset.with_hooks/3
...
argument :password_confirmation, :string do
allow_nil? false
sensitive? true
end
validate AshAuthentication.Strategy.Password.PasswordConfirmationValidation
argument :password_confirmation, :string do
allow_nil? false
sensitive? true
end
validate AshAuthentication.Strategy.Password.PasswordConfirmationValidation
** (Ash.Error.Framework) Framework Error
* Assumption failed: Action does not correlate with an authentication strategy
This should not be possible, please report a detailed bug at:
https://github.com/ash-project/ash/issues/new?assignees=&labels=bug%2C+needs+review&template=bug_report.md&title=
(ash 2.10.2) lib/ash/api/api.ex:2123: Ash.Api.unwrap_or_raise!/3
(lpe 0.1.0-81ecaa1) priv/repo/seeds/dev_data_seed.ex:20: LpePriv.Seeds.DevDataSeed.seed/0
priv/repo/seeds.exs:19: (file)
(elixir 1.15.0) lib/code.ex:1432: Code.require_file/2
...
** (Ash.Error.Framework) Framework Error
* Assumption failed: Action does not correlate with an authentication strategy
This should not be possible, please report a detailed bug at:
https://github.com/ash-project/ash/issues/new?assignees=&labels=bug%2C+needs+review&template=bug_report.md&title=
(ash 2.10.2) lib/ash/api/api.ex:2123: Ash.Api.unwrap_or_raise!/3
(lpe 0.1.0-81ecaa1) priv/repo/seeds/dev_data_seed.ex:20: LpePriv.Seeds.DevDataSeed.seed/0
priv/repo/seeds.exs:19: (file)
(elixir 1.15.0) lib/code.ex:1432: Code.require_file/2
...
2 Replies
👋 sorry this one got by me. Did you ever figure this out?
I am pretty sure what will fix it is passing the strategy to the change:
(presuming your password strategy is named
create :seed do
accept [
:email,
:username,
:first_name,
:last_name,
]
argument :password, :string do
allow_nil? false
sensitive? true
end
change {AshAuthentication.Strategy.Password.HashPasswordChange, strategy_name: :password}
end
create :seed do
accept [
:email,
:username,
:first_name,
:last_name,
]
argument :password, :string do
allow_nil? false
sensitive? true
end
change {AshAuthentication.Strategy.Password.HashPasswordChange, strategy_name: :password}
end
:password
.