<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to get populated user.data after user registraion.]]></title><description><![CDATA[<p dir="auto">Hi.<br />
I use user.registration.create webhook to put additional info to user.data object.<br />
And I try to get this data in lambda function to populate access JWT.<br />
I setup user.registration.create webhook transaction to get all webhook with success result.<br />
I see in logs that user.data was populate.<br />
I see empty data in lambda log and JWT after registration.<br />
But I see data in  lambda log and JWT after success login.</p>
<p dir="auto">So the question is what I am need to get JWT token with populated user.data after registration?</p>
<p dir="auto">FA version [1.31.0]</p>
]]></description><link>https://fusionauth.io/community/forum/topic/1443/how-to-get-populated-user-data-after-user-registraion</link><generator>RSS for Node</generator><lastBuildDate>Mon, 20 Jul 2026 13:33:36 GMT</lastBuildDate><atom:link href="https://fusionauth.io/community/forum/topic/1443.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 30 Dec 2021 12:59:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to get populated user.data after user registraion. on Mon, 10 Jan 2022 18:31:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/1292">@muravyov-alexey</a> Thank you!</p>
]]></description><link>https://fusionauth.io/community/forum/post/4172</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/4172</guid><dc:creator><![CDATA[dan]]></dc:creator><pubDate>Mon, 10 Jan 2022 18:31:40 GMT</pubDate></item><item><title><![CDATA[Reply to How to get populated user.data after user registraion. on Mon, 10 Jan 2022 17:41:57 GMT]]></title><description><![CDATA[<p dir="auto">I'v created a bug report<br />
<a href="https://github.com/FusionAuth/fusionauth-issues/issues/1545" rel="nofollow ugc">https://github.com/FusionAuth/fusionauth-issues/issues/1545</a></p>
]]></description><link>https://fusionauth.io/community/forum/post/4170</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/4170</guid><dc:creator><![CDATA[muravyov.alexey]]></dc:creator><pubDate>Mon, 10 Jan 2022 17:41:57 GMT</pubDate></item><item><title><![CDATA[Reply to How to get populated user.data after user registraion. on Fri, 07 Jan 2022 15:38:15 GMT]]></title><description><![CDATA[<p dir="auto">hi <a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/1292">@muravyov-alexey</a> ,</p>
<p dir="auto">Hmmm. That seems like it should work, or be clearly documented that on the first user creation, nothing added by a webhook is going to be available in the user object.</p>
<p dir="auto">Can you please file a bug here: <a href="https://github.com/fusionauth/fusionauth-issues/issues" rel="nofollow ugc">https://github.com/fusionauth/fusionauth-issues/issues</a> with the replication steps you have outlined? You can also link to this forum post.</p>
<p dir="auto">Other things you can try:</p>
<ul>
<li>using the non transactional webhook to do the update</li>
<li>preloading your users by bulk loading from auth0, as outlined here: <a href="https://fusionauth.io/docs/v1/tech/migration-guide/auth0/" rel="nofollow ugc">https://fusionauth.io/docs/v1/tech/migration-guide/auth0/</a></li>
</ul>
]]></description><link>https://fusionauth.io/community/forum/post/4161</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/4161</guid><dc:creator><![CDATA[dan]]></dc:creator><pubDate>Fri, 07 Jan 2022 15:38:15 GMT</pubDate></item><item><title><![CDATA[Reply to How to get populated user.data after user registraion. on Wed, 05 Jan 2022 14:46:28 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/20">@dan</a>.<br />
Yes, I have read this article before about transactional webhooks. But there is lack of information which of events come after which.<br />
Let me give more details.<br />
I try add userId from custom database to JWT (it is legacy code that I try to migrate from auth0 to fusionauth, so for the moment I can't drop this)<br />
For the first time user not exist in FA's databse and not exist in custom database.</p>
<ol>
<li>on a user.create event in webhook I create user record in custom DB (I know here I can't use FA's API to update user because transactions)</li>
<li>on a user.registration event we already have saved user in FA's DB and in custom DB, so I use FA's API in webhook to put userId in FA's user.data object</li>
<li>I use populate access token lamda to get userId from user.data object and put it to JWT access token.</li>
</ol>
<p dir="auto">But it looks like 3rd step happends earlier then 2nd because<br />
in browser I put email/password and my app get token without userId. But if I logout and then login to application then I have userId in token.<br />
So I think we create JWT access token early than create user and populate user.data on user.registration event.</p>
<p dir="auto">I supposed that user.registration event happens before JWT populate lambda. And I supposed that user.registration event is transactional and the JWT populate lambda wait when user.registration event will be finished.</p>
<p dir="auto">Lambda to populate JWT:</p>
<pre><code>function populate(jwt, user, registration) {
  if (!user.data || !user.data.userId) {
    return;
  }

  var namespace = 'https://mydomain.com/';
  var customUser = {
    id: user.data.userId
  };
  
  jwt[namespace + 'userId'] = customUser.id;
}
</code></pre>
<p dir="auto">Webhook for 'user.registration.create' event:</p>
<pre><code>private async populateFusionAuthUser(event: FusionAuthEvent) {
    let user = undefined;
    if (event.user.data &amp;&amp; event.user.data.userId) {
        logger.info('FusionAuth user already populated');
        return;
    }
    if (event.user.email &amp;&amp; event.user.verified) {
        user = await this.authService.getUser(event.user.email);
    }
    if (user) {
        const patchBody = {
            user: {
                email: event.user.email,
                data: {
                    userId: user.id
                }
            },
        }
        await this.fusionAuthService.updateUser(event.user.id, patchBody);
        logger.info('FusionAuth user populated');
    }
}
</code></pre>
]]></description><link>https://fusionauth.io/community/forum/post/4150</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/4150</guid><dc:creator><![CDATA[muravyov.alexey]]></dc:creator><pubDate>Wed, 05 Jan 2022 14:46:28 GMT</pubDate></item><item><title><![CDATA[Reply to How to get populated user.data after user registraion. on Tue, 04 Jan 2022 12:48:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/1292">@muravyov-alexey</a></p>
<p dir="auto">So, to repeat back the problem, you are augmenting <code>user.data</code> in a <code>user.registration.create</code> webhook and the data is stored on the user after successful login, but not available in the populate JWT lambda to be put in the generated JWT? Is that correct?</p>
<p dir="auto">There are issues with modifying data in transactional webhooks. More on that here: <a href="https://fusionauth.io/docs/v1/tech/events-webhooks/writing-a-webhook/#calling-fusionauth-apis-in-webhooks" rel="nofollow ugc">https://fusionauth.io/docs/v1/tech/events-webhooks/writing-a-webhook/#calling-fusionauth-apis-in-webhooks</a></p>
<p dir="auto">Does this user exist already or are they being newly created? Can you provide the webhook code for examination?</p>
]]></description><link>https://fusionauth.io/community/forum/post/4140</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/4140</guid><dc:creator><![CDATA[dan]]></dc:creator><pubDate>Tue, 04 Jan 2022 12:48:12 GMT</pubDate></item></channel></rss>