Roles drop down in new user management module empty

The 5.10 release notes say this about roles in SS Studio user module:

“Assigning Roles & Permissions which are auto populated from the Required & Validation Roles/Permission Attributes used in your App”

In my app I am using [RequiresAnyRole( ... ))] and [RequiredRole( ... )] but the roles drop down is not populating any of my roles.

Where should I add roles so they generate inside the role dropdown in new user manager?

They should inferred automatically from your Attribute usage, are any custom roles appearing? Can you repro this issue in a new project? e.g. a fork of https://github.com/NetCoreApps/BookingsCrud that includes a protected Service with Roles that don’t appear?

It’s better for ServiceStack to automatically aggregate the roles, but you can also ensure Roles are added by registering an AppMetadata Filter after the plugins ar run to the AdminUsers metadata, e.g:

AfterInitCallbacks.Add(host => 
    host.AssertPlugin<MetadataFeature>().AppMetadataFilters.Add(meta => {
        meta.Plugins.AdminUsers.AllRoles.AddIfNotExists("TheRole");
    }));

Here is a new project repro: https://github.com/GuerrillaCoder/RoleTest

No roles are being generated.

image

If I manually add a role in DB it detects that the role exists and gives me option to remove it but wont let me add it still:

image

I am not using Autocrud, I am protecting endpoints like so: https://github.com/GuerrillaCoder/RoleTest/blob/master/RoleTest.ServiceInterface/MyServices.cs

Does user object have to be using the auto crud features for the roles to be detected?

I don’t understand what the issue is, the custom role is appearing in the UI:

image

I’m able to create a new user with the role, remove it, save it, re-add it, save it, etc. Everything’s working as expected. What is the issue and what are the exact steps to repro it?

Also you don’t need to use [RequiresAnyRole] with Admin role as it’s a super user role that can already access all protected services and when you use any of the [Require*] Auth Attributes it also implicitly requires Authentication so you can just use a single [RequiredRole] attribute instead, e.g:

// [Authenticate]
// [RequiresAnyRole("Admin", "SubSite")]
[RequiredRole("SubSite")]

The issue for me is I don’t see the roles in the drop down. If I click on it nothing happens. Clicking on it makes it look like the screenshots in my previous post. I dont see the 2 roles that you have screenshot in the dropdown inside ss studio.

Here is screencapture:

Strange that we’re seeing different behavior in the same App. Can you update the app tool if you haven’t already so you’re also running the latest version of Chromium:

$ dotnet tool update -g app

If it’s still an issue can you launch Studio in debug mode:

app://studio?debug

Then hit F12 to bring up the Debug Inspector and run the following in the command line:

> require('./shared').store.getApp('localhost_5001').plugins.adminUsers.allRoles

This should return the roles in the App i.e. an observable array of ["Admin", "SubSite"]. If it does then I’m assuming you have a JS error preventing the drop down from working, can you go through the console history and paste any JS Exceptions that might cause the issue.

If I run it in debug mode then it works fine and drop down populates with no errors. if I load it with app open studio command then the drop down does not populate.

So it seems if I go to app://studio in browser it also works fine. The issue is confined to when using the app open studio command.

Are you sure? app://studio is an alias for app open studio which I’ve run to test that it’s also working as expected without issue.

Maybe you had an old version of the app tool and it just works now?

Still getting behaviour of it not working when opening from command line but it works from browser so all good :slight_smile: