From 325b52eca0edcd8c24f4ede010f5350f54e212d2 Mon Sep 17 00:00:00 2001 From: James Harton Date: Tue, 30 Apr 2024 10:04:54 +1200 Subject: [PATCH] fix(Jwt): Include authentication interaction context when storing tokens. --- lib/ash_authentication/jwt.ex | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/ash_authentication/jwt.ex b/lib/ash_authentication/jwt.ex index 33b8f3e..4b5ef22 100644 --- a/lib/ash_authentication/jwt.ex +++ b/lib/ash_authentication/jwt.ex @@ -120,17 +120,18 @@ defmodule AshAuthentication.Jwt do defp maybe_store_token(token, resource, user, purpose, opts) do if Info.authentication_tokens_store_all_tokens?(resource) do with {:ok, token_resource} <- Info.authentication_tokens_token_resource(resource) do + context_patch = %{ + ash_authentication: %{user: user}, + private: %{ash_authentication?: true} + } + TokenResource.Actions.store_token( token_resource, %{ "token" => token, "purpose" => to_string(purpose) }, - Keyword.put(opts, :context, %{ - ash_authentication: %{ - user: user - } - }) + Keyword.update(opts, :context, context_patch, &Map.merge(&1, context_patch)) ) end else