# Can't assign Default Roles to a User on Sign up Using Auth0 Actions

**URL:** <https://community.auth0.com/t/cant-assign-default-roles-to-a-user-on-sign-up-using-auth0-actions/193580>\
**Category:** Get Help\
**Tags:** new-universal-login-experience, login-experience\
**Created:** [October 24, 2025, 2:16pm UTC](https://community.auth0.com/t/cant-assign-default-roles-to-a-user-on-sign-up-using-auth0-actions/193580 "2025-10-24T14:16:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![loihnt05](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/loihnt05/32/77165_2.png) [@loihnt05](https://community.auth0.com/u/loihnt05)\
**Post date:** [October 24, 2025, 2:16pm UTC](https://community.auth0.com/t/cant-assign-default-roles-to-a-user-on-sign-up-using-auth0-actions/193580/1 "2025-10-24T14:16:27Z")

</div>

My code:

```typescript
exports.onExecutePostLogin = async (event, api) => {
   if (event.authorization && event.authorization.roles && event.authorization.roles.length > 0) {
    return;
  }
  // Create management API client instance
  const { ManagementClient } = require("auth0"); 
  // or use : const ManagementClient = require("auth0").ManagementClient;
  // also get same error.

  const management = new ManagementClient({
    domain: event.secrets.domain,
    clientId: event.secrets.clientId,
    clientSecret: event.secrets.clientSecret,
  });

  const params = { id : event.user.user_id };
  const data = { "roles" : [event.secrets.default_roles] };

  try {
    await management.users.assignRoles(params, data);
  } catch (e) {
    console.log(`Error assigning default role: ${e.message}`);
  }
};

```

Dependency: auth0@latest  
All variable environment created successful.

Node v22

This is the error:

```typescript
Error assigning default role: management.users.assignRoles is not a function

```

I learned code from youtube: Assigning Default Roles to a User on Sign up Using Auth0 Actions. But I couldn’t make. Help me please!

---

<div class="post-metadata">

**Author:** ![teodor.andrei](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/teodor.andrei/32/75320_2.png) [@teodor.andrei](https://community.auth0.com/u/teodor.andrei)\
**Post date:** [October 24, 2025, 2:46pm UTC](https://community.auth0.com/t/cant-assign-default-roles-to-a-user-on-sign-up-using-auth0-actions/193580/3 "2025-10-24T14:46:12Z")

</div>

Hi @loihnt05 and welcome to the Auth0 Community!

Please allow me some time to look into your issue, and I will get back to you as soon as possible.

Thanks!  
Teodor.

---

<div class="post-metadata">

**Author:** ![vlad.murarasu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vlad.murarasu/32/72793_2.png) [@vlad.murarasu](https://community.auth0.com/u/vlad.murarasu)\
**Post date:** [October 24, 2025, 4:12pm UTC](https://community.auth0.com/t/cant-assign-default-roles-to-a-user-on-sign-up-using-auth0-actions/193580/5 "2025-10-24T16:12:54Z")

</div>

Hi @loihnt05

Welcome to the Auth0 Community!

The reason you receive this error is that the `users` object doesn’t contain an `assignRoles` method. In the link below, you’ll find the documentation on how to assign roles to users.

> **[Roles | Auth0 Node.js SDK - v5.0.0](https://auth0.github.io/node-auth0/classes/management.SDK.Roles-2.html#assign)**
>
> Documentation for Auth0 Node.js SDK

If you have any other questions, feel free ot reach out.

Have a good one,  
Vlad

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [November 7, 2025, 4:13pm UTC](https://community.auth0.com/t/cant-assign-default-roles-to-a-user-on-sign-up-using-auth0-actions/193580/6 "2025-11-07T16:13:15Z")

</div>

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