weljoda

weljoda

Guidance on extending Magic Link registration with GDPR consent and marketing opt-in

Hi,

I am currently working on customizing the user registration workflow when using the Magic Link strategy in Ash Authentication. Specifically, I need to:

  1. Inform users about GDPR regulations.
  2. Add a checkbox for opting in to receive marketing emails.

I’ve already gone through this blog post and several forum discussions. I understand how this works with password-based registration, but the Magic Link flow makes it trickier because:

  • The user record is only created after the link has been clicked and the “Sign in” button is pressed (which I actually like as a flow).

  • As far as I can tell, the email address is not stored in the token resource, but rather inside the JWT token that gets sent in the email.

  • I also noticed that there is an extra_data attribute, so I’m considering two possible approaches:

    • Storing the registration page data in the JWT itself.
    • Storing it in the extra_data attribute.

In the blog example, password registration uses:

Ash.Changeset.for_create(:register_with_password, %{email: "abc@gmail.com", password: "password", username: "username123"})

But for Magic Link registration there seems to be nothing similar on the token resource. Instead, the sign_in_with_magic_link create action on the user uses the JWT to determine the email address.

I also reviewed the implementation here in the source code. The token is created with Jwt.token_for_user and includes only the identity_field (email in this case):

%{
  "act" => strategy.sign_in_action_name,
  "identity" => Map.get(user, strategy.identity_field)
}

This seems to leave no obvious way of adding additional values.

My question: Is there any recommended approach for passing additional information (e.g. GDPR consent, marketing opt-in) through the Magic Link registration flow?

Thanks a lot for your guidance!

First Post!

zachdaniel

zachdaniel

Creator of Ash

I believe as of the branch on main, the source_context is passed into the sender via opts. So on requesting a magic link you can set information like that on the url itself, and then I believe you can add arguments to the sign_in_with_magic_link action that match the names of the other query parameters. then you can update attributes on the created user that way.

Where Next?

Popular in Questions Top

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
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
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
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
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New

Other popular topics Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
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 41989 114
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31265 143
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
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
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
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

Latest on Elixir Forum

We're in Beta

About us Mission Statement