defmodule Mv.Accounts do @moduledoc """ AshAuthentication specific domain to handle Authentication for users. """ use Ash.Domain, extensions: [AshAdmin.Domain, AshPhoenix] admin do show? true end resources do resource Mv.Accounts.User do define :create_user, action: :create_user define :list_users, action: :read define :update_user, action: :update_user define :destroy_user, action: :destroy define :create_register_with_rauthy, action: :register_with_rauthy define :read_sign_in_with_rauthy, action: :sign_in_with_rauthy end resource Mv.Accounts.Token end @doc """ Register a new user with password using AshAuthentication's standard action. This creates a user and the notifier will automatically create a member. """ def register_with_password(params) do # Use AshAuthentication's standard register_with_password action Mv.Accounts.User |> Ash.Changeset.for_create(:register_with_password, params) |> Ash.create(domain: __MODULE__) end end