Ash FrameworkAF
Ash Framework3y ago
5 replies
lpmay

Can You Add Additional Attributes to ash_authentication_phoenix?

I went through the tutorial for and have password/email auth working. I'd like to add a
role
attribute to my user resource so I did the below:
  attributes do 
    uuid_primary_key :id 
    attribute :email, :ci_string, allow_nil?: false
    attribute :hashed_password, :string, allow_nil?: false, sensitive?: true
    attribute :role, :atom do 
      constraints [one_of: [:admin, :user]]
      default :user
      allow_nil? false
    end
  end


At runtime, the form seems to have errors like this:
ERROR:  column u0.role does not exist at character 51


Is the intent that I can have arbitrary attributes on a user resources used with Ash Authentication like this, or is there another approach I should be looking into? Ultimately, I'd like to add some code to seeds.exs which creates a couple :admin accounts and gate certain features behind only that role, but I'm very new to Ash, Phoenix and Elixir so I'm not sure if I'm heading in the right general direction or not.
Was this page helpful?