diff --git a/lib/accounts/user.ex b/lib/accounts/user.ex index c4c0bbe..6604f91 100644 --- a/lib/accounts/user.ex +++ b/lib/accounts/user.ex @@ -66,10 +66,15 @@ defmodule Mv.Accounts.User do create :create_user do accept [:email, :member_id] + argument :member, :map + change manage_relationship(:member, type: :create) end update :update_user do + require_atomic? false accept [:email, :member_id] + argument :member, :map + change manage_relationship(:member, on_match: :update, on_no_match: :create) end # Admin action for direct password changes in admin panel @@ -118,6 +123,16 @@ defmodule Mv.Accounts.User do |> Ash.Changeset.change_attribute(:oidc_id, user_info["sub"] || user_info["id"]) end end + + create :register_with_password do + accept [:email] + argument :password, :string, allow_nil?: false, sensitive?: true + argument :password_confirmation, :string, allow_nil?: false, sensitive?: true + argument :member, :map + change AshAuthentication.Strategy.Password.HashPasswordChange + change AshAuthentication.GenerateTokenChange + change manage_relationship(:member, type: :create) + end end # Global validations - applied to all relevant actions diff --git a/lib/mv_web/components/member_form_component.ex b/lib/mv_web/components/member_form_component.ex new file mode 100644 index 0000000..15ac008 --- /dev/null +++ b/lib/mv_web/components/member_form_component.ex @@ -0,0 +1,50 @@ +defmodule MvWeb.MemberFormComponent do + use Phoenix.Component + use Gettext, backend: MvWeb.Gettext + import MvWeb.CoreComponents + + @doc """ + Reusable form for member data (without