bobfp

bobfp

Recreating Magic Link flow with Ash Typescript

Hi everyone,

I’m migrating a Magic Link authentication flow from Phoenix LiveView to a SolidJS SPA using Ash TypeScript, and I’m stuck on retrieving the authentication token.

Background

  • Using AshAuthentication’s built-in magic link resources (which worked perfectly out-of-the-box with LiveView)

  • Now building a JS SPA (SolidJS) that needs to interact with the same backend via the RPC client

  • The LiveView implementation handled the token automatically, but I want to manage it manually in the SPA

What I’m trying to do

Recreate the same Magic Link flow in my SPA:

  1. User requests a magic link via email

  2. User clicks the link and is authenticated

  3. The app receives and stores the authentication token for subsequent API calls

Current status

:white_check_mark: Successfully requesting the magic link using AshAuthentication’s request_magic_link action
:white_check_mark: Successfully calling the sign-in-with-magic-link action
:cross_mark: Cannot retrieve the authentication token after sign-in to store it client-side

The problem

From what I can tell, the token appears to be returned via metadata in the response, but the RPC client doesn’t seem to expose this metadata (or I’m not accessing it correctly).

Question

  1. How do I access response metadata (specifically the auth token) from AshAuthentication’s magic link sign-in action through the RPC client?

  2. Is there a different pattern I should be following when using AshAuthentication with a JS SPA instead of LiveView?

Any guidance on properly handling AshAuthentication tokens in a decoupled frontend would be greatly appreciated!

Most Liked

zachdaniel

zachdaniel

Creator of Ash

Ah…right. I think the RPC client may need to be updated to support displaying metadata in its results. You’ll need to open an issue for this :smiley:

Where Next?

Popular in Questions Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
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
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41539 114
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
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
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement