Ash FrameworkAF
Ash Frameworkโ€ข3y agoโ€ข
2 replies
simpers

AshAuthentication error when trying to use password hashing change in seed action

I'm trying to use this action to seed some test accounts:
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

This action has no :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
  ...

If I add
  argument :password_confirmation, :string do
    allow_nil? false
    sensitive? true
  end

  validate AshAuthentication.Strategy.Password.PasswordConfirmationValidation

to the seed action, the error instead becomes:
** (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
    ...
Was this page helpful?