# Social Media app - using auth0 roles

**URL:** <https://community.auth0.com/t/social-media-app-using-auth0-roles/82389>\
**Category:** Get Help\
**Tags:** auth0, roles\
**Created:** [April 26, 2022, 7:21am UTC](https://community.auth0.com/t/social-media-app-using-auth0-roles/82389 "2022-04-26T07:21:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![raph90](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/raph90/32/36888_2.png) [@raph90](https://community.auth0.com/u/raph90)\
**Post date:** [April 26, 2022, 7:21am UTC](https://community.auth0.com/t/social-media-app-using-auth0-roles/82389/1 "2022-04-26T07:21:23Z")

</div>

I’m putting together a small social media app, and have the following use case.

- Users are allowed to create groups
- Certain users are admins of the group

Is it possible for me to use auth0 roles to determine if a user is an admin of a group or not? This would involve me somehow creating roles dynamically from my application and posting them to Auth0…

Or is the better way (and the way I’m currently doing it) just to avoid using Auth0 for this, and simply check if any given user is an admin of a given group in my application?

I’m just wondering if roles are ever used for this sort of use case.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [April 27, 2022, 1:04am UTC](https://community.auth0.com/t/social-media-app-using-auth0-roles/82389/3 "2022-04-27T01:04:50Z")

</div>

Hi there @raph90 welcome to the community!

> [@raph90](#):
>
> Is it possible for me to use auth0 roles to determine if a user is an admin of a group or not? This would involve me somehow creating roles dynamically from my application and posting them to Auth0…

You can create roles/permissions in Auth0 however you see fit, so grouping some users as admin is certainly possible. Here’s a general overview of how roles work in an access control context:

> **[Role-Based Access Control](https://auth0.com/docs/manage-users/access-control/rbac)**
>
> Understand the concept of role-based access control and how it applies in Auth0.

Regarding creating them from your application, you might want to look into using the Management API, in particular [api/v2/roles](https://auth0.com/docs/api/management/v2#!/Roles/post_roles).

Lastly, you would probably be interested in adding these roles to an Access and/or ID Token. You can achieve that with something like:

```auto
exports.onExecutePostLogin = async (event, api) => {
  const namespace = 'https://my-app.example.com';
  if (event.authorization) {
    api.idToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
    api.accessToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
    
  }
}

```

Some more on adding custom claims to Actions here:

> **[Adding Custom Claims to ID Tokens with Auth0 Actions](https://auth0.com/blog/adding-custom-claims-to-id-token-with-auth0-actions/)**
>
> Learn how to create a new custom Action that will add a custom claim to your Auth0-issued ID Token

Hope this helps to clear things up a bit!

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [May 12, 2022, 1:05am UTC](https://community.auth0.com/t/social-media-app-using-auth0-roles/82389/4 "2022-05-12T01:05:46Z")

</div>

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