sezaru

sezaru

AshAuthentication password_reset_with_password fails when called by AshGraphQL

When calling password_reset_with_password from AshGraphQL it will fail since the update mutation expects me to be logged.

Calling the action directly from IEX works fine.

Here is how I added it to my graphql block:

graphql do
    ...

    mutations do
      update :password_reset_with_password, :password_reset_with_password do
        identity false
      end

      ...
    end
  end

This is how I’m calling it:

passwordResetWithPassword(
  input: {
    password: "12345678"
    passwordConfirmation: "12345678"
    resetToken: "my reset token"
  }
) {
  metadata {
    token
  }
  result {
    fullName
    email
  }
  errors {
    message
  }
}

From the terminal, I get this error:

SELECT u0."id", u0."email", u0."hashed_password", u0."phone_number", u0."first_name", u0."surname", u0."roles", u0."organization_roles", u0."confirmed_at", u0."active?", u0."referral_code", u0."normalized_full_name", u0."inserted_at", u0."updated_at", u0."organization_id", u0."created_by_id", u0."referred_by_id" FROM "users" AS u0 []
[warning] `1a4e5e6f-8131-42b8-bcdb-bc3e71bc818b`: AshGraphql.Error not implemented for error:
** (Ash.Error.Invalid.MultipleResults) expected at most one result but got at least 15.
      
      Please ensure your action is configured with an appropriate filter to ensure a single result is returned.
    (ash 2.14.17) lib/ash/api/api.ex:1948: Ash.Api.unwrap_one/1
    (ash 2.14.17) lib/ash/api/api.ex:1930: Ash.Api.unwrap_one/1
    (marketplace 1.3.2) lib/marketplace/accounts.ex:1: Marketplace.Accounts.read_one/2
    (ash_graphql 0.26.6) lib/graphql/resolver.ex:1137: AshGraphql.Graphql.Resolver.mutate/2
    (absinthe 1.7.5) lib/absinthe/phase/document/execution/resolution.ex:234: Absinthe.Phase.Document.Execution.Resolution.reduce_resolution/1
    (absinthe 1.7.5) lib/absinthe/phase/document/execution/resolution.ex:189: Absinthe.Phase.Document.Execution.Resolution.do_resolve_field/3
    (absinthe 1.7.5) lib/absinthe/phase/document/execution/resolution.ex:174: Absinthe.Phase.Document.Execution.Resolution.do_resolve_fields/6
    (absinthe 1.7.5) lib/absinthe/phase/document/execution/resolution.ex:145: Absinthe.Phase.Document.Execution.Resolution.resolve_fields/4
    (absinthe 1.7.5) lib/absinthe/phase/document/execution/resolution.ex:88: Absinthe.Phase.Document.Execution.Resolution.walk_result/5
    (absinthe 1.7.5) lib/absinthe/phase/document/execution/resolution.ex:67: Absinthe.Phase.Document.Execution.Resolution.perform_resolution/3
    (absinthe 1.7.5) lib/absinthe/phase/document/execution/resolution.ex:24: Absinthe.Phase.Document.Execution.Resolution.resolve_current/3
    (absinthe 1.7.5) lib/absinthe/pipeline.ex:408: Absinthe.Pipeline.run_phase/3
    (absinthe_plug 1.5.8) lib/absinthe/plug.ex:536: Absinthe.Plug.run_query/4
    (absinthe_plug 1.5.8) lib/absinthe/plug.ex:290: Absinthe.Plug.call/2
    (phoenix 1.7.9) lib/phoenix/router/route.ex:42: Phoenix.Router.Route.call/2
    (phoenix 1.7.9) lib/phoenix/router.ex:432: Phoenix.Router.__call__/5
    (marketplace 1.3.2) lib/marketplace_web/endpoint.ex:1: MarketplaceWeb.Endpoint.plug_builder_call/2
    (marketplace 1.3.2) deps/plug/lib/plug/debugger.ex:136: MarketplaceWeb.Endpoint."call (overridable 3)"/2
    (marketplace 1.3.2) lib/marketplace_web/endpoint.ex:1: MarketplaceWeb.Endpoint."call (overridable 4)"/2
    (marketplace 1.3.2) lib/marketplace_web/endpoint.ex:1: MarketplaceWeb.Endpoint.call/2
    (phoenix 1.7.9) lib/phoenix/endpoint/sync_code_reload_plug.ex:22: Phoenix.Endpoint.SyncCodeReloadPlug.do_call/4
    (plug_cowboy 2.6.1) lib/plug/cowboy/handler.ex:11: Plug.Cowboy.Handler.init/2
    (cowboy 2.10.0) /home/jeferson/workspace/rebuilt/platform/marketplace/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
    (cowboy 2.10.0) /home/jeferson/workspace/rebuilt/platform/marketplace/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
    (cowboy 2.10.0) /home/jeferson/workspace/rebuilt/platform/marketplace/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3
    (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3

Seems like it is trying to find a user, but since I’m not logged (I mean, I’m resetting the password, so I can’t be logged first since I don’t know the initial password anyway), it will just query the full users table without a filter.

Marked As Solved

zachdaniel

zachdaniel

Creator of Ash

Okay, gotcha, so, set identity :unique_email (or whatever the identity is that users use to log in).

Where Next?

Popular in Questions Top

_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 126479 1222
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement