How can I define another action apart from register_with_password
for creating users? My implementation here for the register_with_password
(overrides the one from AshAuthentication
) action accepts an organization
argument as a map, this creates a user and an organization. Now I want define another action for creating organization users(like an admin adding users to an org), this action will accept an organization_id
instead, since an organization already exists and am just relating it to a user. I have tried to duplicate the register_with_password
with a different name like this:
create :register_internal_user do
allow_nil_input [:hashed_password]
accept [:email]
argument :password, :string do
sensitive? true
constraints min_length: 8, max_length: 32
end
argument :password_confirmation, :string do
sensitive? true
constraints min_length: 8, max_length: 32
end
argument :user_profile, :map, allow_nil?: false
argument :organization_id, :uuid, allow_nil?: false
validate AshAuthentication.Strategy.Password.PasswordConfirmationValidation
change AshAuthentication.Strategy.Password.HashPasswordChange
change AshAuthentication.GenerateTokenChange
change manage_relationship(:organization_id, :organization, type: :append_and_remove)
change manage_relationship(:user_profile, type: :direct_control)
end
action but am getting an error in the changeset:
...
errors: [
%Ash.Error.Framework.AssumptionFailed{
message: "Action does not correlate with an authentication strategy",
splode: nil,
bread_crumbs: [],
vars: [],
path: [],
stacktrace: #Splode.Stacktrace<>,
class: :framework
}
]
...
How can I implement this action?