Auth0 Home Blog Docs

Simple multi role asp.net mvc example


#1

I’m trying to find out the easiest way to create a set of users that have a few different roles.

I’m a c# ASP.Net MVC core developer using Auth0. I used this QuickStart is what I used to get me going

I’ve got my Web App running with Auth0 such that I can check

  1. if the user has been authenticated and
  2. if they have been verified.

Currently It can also detect which user has the admin role (or just a user role). I did this by creating a rule based on roles-creation.

I can determine who gets access to my admin view by adding this to my controller like so…

  [HttpGet]
  [Authorize(Roles = "admin")]  
  public async Task<IActionResult> Admin()
  {
   return View();
  }
`

Based on the rule I've created, it's either **admin** or **user**, and I need to have multiple roles for specific users.  What's the best/easiest way to do that?

###To many options
1. should I use  Auth0 Authorization extension
2. should I tweek the current rule I'm using so that a set of users can be assigned 1 or more roles
3. should I go to each individual user and modify the json for the **user_metadata**
4. should I go to each individual user and modify the json for the **app_metadata**

### Tweaks
I tweaked around trying various things, but I just don't know enough to figure out what to do.


I thought I would try this forum.  Any help would be appreciated.
Thanks,
John