gvanders
gvanders
AEAsh Elixir
Created by gvanders on 5/10/2023 in #support
Polymorphic Embedded Resources?
Grabbing the value of the union type returns an Ash.Resource struct. Are you thinking to then feed that in to an additional AshPhoenix.Form.for_update? My first thought was to implement it similar to multi-step forms where changing the tag value changed the nested form , but I haven't made one of those yet so thats all in theory
14 replies
AEAsh Elixir
Created by gvanders on 5/10/2023 in #support
Polymorphic Embedded Resources?
🫡
14 replies
AEAsh Elixir
Created by roberts.gulans on 5/4/2023 in #support
How to create organization after user creation.
16 replies
AEAsh Elixir
Created by gvanders on 4/28/2023 in #support
Nested embedded Resource Form
I'll take a look! Thanks for all the help 🙂
28 replies
AEAsh Elixir
Created by gvanders on 4/28/2023 in #support
Nested embedded Resource Form
ahhh sorry that question was to a comment earlier in the thread
28 replies
AEAsh Elixir
Created by gvanders on 4/28/2023 in #support
Nested embedded Resource Form
Is this something I'd implement on my side? Or that we'd add to AshPhoenix?
28 replies
AEAsh Elixir
Created by gvanders on 4/28/2023 in #support
Nested embedded Resource Form
Then I'd have to know ahead of time which are nil. Which I guess is easy. If I have the data option set, I assume it shouldn't matter if the form is clobbered?
|> AshPhoenix.Form.add_form(:background, type: :update, data: styles.background)
|> AshPhoenix.Form.add_form(:background, type: :update, data: styles.background)
28 replies
AEAsh Elixir
Created by gvanders on 4/28/2023 in #support
Nested embedded Resource Form
Mmm yeah probably simplest if I just keep the add_form
28 replies
AEAsh Elixir
Created by gvanders on 4/28/2023 in #support
Nested embedded Resource Form
I'm parsing a tailwind string into resources, and then converting it back to string after form is submitted. So I just need to make sure theres an empty resource
28 replies
AEAsh Elixir
Created by gvanders on 4/28/2023 in #support
Nested embedded Resource Form
Since that looks right, just checked something. In the actual data, I had one of the embedded resources set to nil (the second one). When it's not nil it appears. Sorry for that. I don't know if Ash should handle that case, but I'll make sure theres default empty structs
28 replies
AEAsh Elixir
Created by gvanders on 4/28/2023 in #support
Nested embedded Resource Form
Took out the Keyword.get(:forms before the map
28 replies
AEAsh Elixir
Created by gvanders on 4/19/2023 in #support
Reading Tenant ETS resources returns empty array
10 replies
AEAsh Elixir
Created by gvanders on 4/19/2023 in #support
Reading Tenant ETS resources returns empty array
For ETS, it seems like the implementation details don't really matter like they do for postgres, so maybe it's enough to make sure the tenant field in the map isn't nil? Theres some add_tenant functions which only trigger for :context
10 replies
AEAsh Elixir
Created by gvanders on 4/19/2023 in #support
Reading Tenant ETS resources returns empty array
Yep attribute multi-tenancy
10 replies
AEAsh Elixir
Created by gvanders on 4/19/2023 in #support
Reading Tenant ETS resources returns empty array
As far as I can tell the tenant is nil on the read path, so it doesn't look in the right table. This is for attribute multitenancy, not sure about context.
10 replies
AEAsh Elixir
Created by gvanders on 4/19/2023 in #support
Reading Tenant ETS resources returns empty array
I can see the tenant table created and can get the data out with tab2list, so issue looks to be on the read path
10 replies
AEAsh Elixir
Created by gvanders on 4/18/2023 in #support
Patterns for Propagating Tenants to LiveComponents/LiveViews?
ahhh gotcha. Thanks 🙂
14 replies
AEAsh Elixir
Created by gvanders on 4/18/2023 in #support
Patterns for Propagating Tenants to LiveComponents/LiveViews?
Is the tenant always accessible via :_tenant in the DSLs??
14 replies
AEAsh Elixir
Created by gvanders on 4/18/2023 in #support
Patterns for Propagating Tenants to LiveComponents/LiveViews?
Not sure if I should make a new thread for this but I'm confused as to how to implement PubSub to work with tenants? If I have a pubsub notifier which says when something is added, and is added to the a list, I will get updates across tenant. Seems like I'll need to prefix a tenant_id somehow?
14 replies
AEAsh Elixir
Created by gvanders on 4/17/2023 in #support
AshAuthenticationPhoenix Override Register Form
For completeness, the way I achieved this was by making a custom SignInLive, which was basically a copy of SignIn component in AshAuthentication.Phoenix, just with <:registry_extra> used in the strategy slot. I did not end up sticking with this, and instead created a default tenant on sign-in via
create :register_with_tenant do
accept([:email])
argument(:password, :string, allow_nil?: false, sensitive?: true)
argument(:password_confirmation, :string, allow_nil?: true, sensitive?: true)
change({AshAuthentication.Strategy.Password.HashPasswordChange, strategy_name: :password})
change({AshAuthentication.GenerateTokenChange, strategy_name: :password})

validate(AshAuthentication.Strategy.Password.PasswordConfirmationValidation)

change(fn changeset, _ ->
Ash.Changeset.manage_relationship(changeset, :organization, %{}, type: :create)
end)
end
create :register_with_tenant do
accept([:email])
argument(:password, :string, allow_nil?: false, sensitive?: true)
argument(:password_confirmation, :string, allow_nil?: true, sensitive?: true)
change({AshAuthentication.Strategy.Password.HashPasswordChange, strategy_name: :password})
change({AshAuthentication.GenerateTokenChange, strategy_name: :password})

validate(AshAuthentication.Strategy.Password.PasswordConfirmationValidation)

change(fn changeset, _ ->
Ash.Changeset.manage_relationship(changeset, :organization, %{}, type: :create)
end)
end
signed in with this action
read :sign_in_with_tenant do
# argument(:email, Ash.Type.CiString, allow_nil?: false)
get? true
# argument(:password, :string, allow_nil?: false, sensitive?: true)

# prepare(AshAuthentication.Strategy.Password.SignInPreparation)
prepare(build(load: [:organization]))
end
read :sign_in_with_tenant do
# argument(:email, Ash.Type.CiString, allow_nil?: false)
get? true
# argument(:password, :string, allow_nil?: false, sensitive?: true)

# prepare(AshAuthentication.Strategy.Password.SignInPreparation)
prepare(build(load: [:organization]))
end
With these options
get_by_subject_action_name :sign_in_with_tenant
strategies do
password :password do
identity_field(:email)
register_action_name(:register_with_tenant)
end
get_by_subject_action_name :sign_in_with_tenant
strategies do
password :password do
identity_field(:email)
register_action_name(:register_with_tenant)
end
Really loved how the custom actions were validated! Was not expecting that and was able to just follow the error messages for what I was missing @jart
6 replies