fix(Password.Transformer): don't force users to define a hashed_password argument to the register action. (#192)

I'm not sure why I added that. Seems wrong.
This commit is contained in:
James Harton 2023-02-13 11:54:49 +13:00 committed by GitHub
parent 311ff2a42a
commit aa57d8ab51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -153,7 +153,6 @@ defmodule AshAuthentication.Strategy.Password.Transformer do
defp validate_register_action(dsl_state, strategy) do
with {:ok, action} <- validate_action_exists(dsl_state, strategy.register_action_name),
:ok <- validate_allow_nil_input(action, strategy.hashed_password_field),
:ok <- validate_password_argument(action, strategy.password_field, true),
:ok <-
validate_password_argument(
@ -171,27 +170,6 @@ defmodule AshAuthentication.Strategy.Password.Transformer do
end
end
defp validate_allow_nil_input(action, field) do
allowed_nil_fields =
action
|> Map.get(:arguments, [])
|> Stream.filter(&(&1.allow_nil? == true))
|> Stream.map(& &1.name)
|> Stream.concat(Map.get(action, :allow_nil_input, []))
|> Enum.into(MapSet.new())
if MapSet.member?(allowed_nil_fields, field) do
:ok
else
{:error,
DslError.exception(
path: [:actions, :allow_nil_input],
message:
"Expected the action `#{inspect(action.name)}` to allow nil input for the field `#{inspect(field)}`"
)}
end
end
defp validate_password_argument(action, field, true) do
with :ok <- validate_action_argument_option(action, field, :type, [Ash.Type.String]) do
validate_action_argument_option(action, field, :sensitive?, [true])