defmodule Memento.Accounts.User do
use Ash.Resource,
data_layer: AshPostgres.DataLayer,
extensions: [AshAuthentication]
attributes do
uuid_primary_key :id
attribute :email, :ci_string, allow_nil?: false
attribute :hashed_password, :string, allow_nil?: false, sensitive?: true
end
authentication do
api Memento.Accounts
strategies do
password :password do
identity_field :email
sign_in_tokens_enabled? true
end
end
tokens do
enabled? true
token_resource Memento.Accounts.Token
signing_secret fn _, _ ->
Application.fetch_env(:my_app, :token_signing_secret)
end
end
end
postgres do
table "users"
repo Memento.Repo
end
identities do
identity :unique_email, [:email]
end
end
I appreciate any guidance you can provide to solve this one.
You should drop in an IO.inspect on the result of Application.fetch_env there. It is likely returning :error, and its probably returning that because your otp app isn’t called :my_app.
No I don’t! Where should I have that configuration? In the user resource, or in config.exs? I cannot find the reference to how to configure this in the Getting Started guide. Maybe I missed it or simply don’t know where to find it…
or trying to list my users through the dashboard and getting this message: * expected at most one result but got at least 2 in query: #Ash.Query<resource: Memento.Accounts.User, limit: 1000, select: [:id, :email, :hashed_password]>
If I attempt any actions with tokens, the page crashes and I get the error: Invalid value provided for jti: At least one of `jti` or `token` arguments must be present.
I am very new to this so surely I am missing 20 moving pieces. I will tackle that tomorrow after looking at your video tutorial on the admin dashboard.
Thanks a million for your great support today. Looking forward to getting the hang of Ash!