Ash FrameworkAF
Ash Framework6mo ago
17 replies
Shahryar

Can not access to actor from token in create action

Hi sorry, I think I might be making a silly mistake somewhere. As you can see, I don’t have access to the actor in the create action — it’s always nil. However, I don’t have this issue in the read action, where I can access the actor without any problems.

 create :register_with_password do
  description "Register a new user with a email and password."
  ....

  change set_attribute(:email, arg(:email))

  change fn changeset, context ->
    current_tenant = changeset.tenant
    context.actor |> IO.inspect(label: "=-=--==-=-=-=-")

    if current_tenant do
      Ash.Changeset.change_attribute(changeset, :site_id, current_tenant)
    else
      changeset
    end
  end

  validate MishkaCms.Accounts.Validations.MasterUserCreation

  change {MishkaCms.Accounts.Changes.EnforceMasterEmailSeparation, []}
  
  ....
end


But works inside my read action and i can print actor
read :me do
  description "Get the current authenticated user"
  get? true

  filter expr(id == ^actor(:id))

  prepare fn query, _context ->
    query
    |> Ash.Query.load([:permissions, :permission_values])
  end
end


I do not know why?
Thank you in advance and sorry again
Solution
i think i found it i am deleting it in my custom plug
Was this page helpful?