team-alembic / ash_authentication

The Ash Authentication framework
MIT License
96 stars 52 forks source link

Magic link strategy with disabled registration doesn't work #828

Open nonameexists1 opened 2 weeks ago

nonameexists1 commented 2 weeks ago

Here's how the magic link strategy was implemented:

magic_link do
  identity_field :email
  registration_enabled? false

  sender X.Accounts.User.Senders.SendMagicLinkEmail
end

...

read :sign_in_with_magic_link do
  description "Sign in or register a user with magic link."

  argument :token, :string do
    description "The token from the magic link that was sent to the user"
    allow_nil? false
  end

  prepare AshAuthentication.Strategy.MagicLink.SignInPreparation

  metadata :token, :string do
    allow_nil? false
  end
end

With the code above I'm getting this error:

[error] ** (FunctionClauseError) no function clause matching in URI.decode_query/3
(elixir 1.17.2) lib/uri.ex:204: URI.decode_query(nil, %{}, :www_form)
(ash_authentication 4.2.7) lib/ash_authentication/strategies/magic_link/sign_in_preparation.ex:28: AshAuthentication.Strategy.MagicLink.SignInPreparation.prepare/3

When registration is enabled it works as expected

zachdaniel commented 2 weeks ago

@jimsynz sorry I won't be able to address this before I leave, but I imagine this is something that I broke in my recent work making registration possible.