[Solved] Update user with Actions - including email_verified

Hi,

While navigating through the forum, I came across some topics that demonstrate the outdated method for updating user information. (e.g Auth0's Management API v2 to update user profile)

Here is how i implemented step-by-step:

In the PostLogin you will see this snippet:

exports.onExecutePostLogin = async (event, api) => {
}

so, you can get your credentials on: https://manage.auth0.com/dashboard/eu/TENENT_NAME/applications/APP_ID/credentials

after that, you can instance

const ManagementClient = require('auth0').ManagementClient;
        
const management = new ManagementClient({
            domain: event.secrets['AUTH0_DOMAIN'],
            clientId: event.secrets['AUTH0_CLIENT_ID'],
            clientSecret: event.secrets['AUTH0_CLIENT_SECRET']
});

Create the body you want to update: (Auth0 Management API v2)

const data = { email_verified: true };

create the params: (PatchUsersByIdRequest | auth0)

const params =  { id : event.user.user_id};

then:

await management.users.update(params, data)

full code:

exports.onExecutePostLogin = async (event, api) => {
   const ManagementClient = require('auth0').ManagementClient;
    const management = new ManagementClient({
            domain: event.secrets['AUTH0_DOMAIN'],
            clientId: event.secrets['AUTH0_CLIENT_ID'],
            clientSecret: event.secrets['AUTH0_CLIENT_SECRET']
    });
  

 const data = { email_verified: true };
 const params =  { id : event.user.user_id};

   try {
            await management.users.update(params, data)
        } catch (e) {
       // handle
    }
}

Hope help community

Hi @alexandro.oliveira

Thank you for providing solutions for other community members. I’ve saved your post, and make sure to link other community members to it in case they need it. Team Work :smiley:

Thanks

Dawid

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.