AdminUsersFeature crashes with NullReference

I’m testing the AdminUsersFeature, and have added the plugin. The “User Admin” choice shows up in the admin’s menu, but won’t list any users. The Chrome debugger reveals that it fails on this call: AdminQueryUsers which gets a NullReferenceException.

When I start with Visual Studio, I get an exception here

app.UseServiceStack(new Apphost())

stating UserAuth Repository is required to use AdminUsersFeature’. Since I do have an implementation of IUserAuthRepository added in Configure.AuthRepository.cs, I suspect that the problem is that my

        Plugins.Add(new AdminUsersFeature());

is in the wrong place (before the UserAuthRepository has been added to the DI container).

I’m adding it in Configure.AppHost.cs’s Configure(Container container). Where should I be adding it? The docs did’t say other than adding the plugin, and there was no x mix for it.

The AdminUsersFeature checks for IAuthRepository to check for the existence of an Auth Repository, so if your auth repo is registered against IAuthRepository interface that check will pass.

I’ve updated this to check for AppHost.GetAuthRepositoryAsync() instead which supports whether your Custom Auth Provider was registered against IAuthRepository or IAuthRepositoryAsync which will be available in the next version.

Note: ServiceStack only needs an Auth Provider registered against IAuthRepository or IAuthRepositoryAsync, it doesn’t look for the IAuthRepository registered against any of the other interfaces, e.g. IUserAuthRepository/Async or IManageUsers/Async.

1 Like

Thanks, I’m using the Async version, so that might be it.

Regarding your note, does this mean that if should implement both IUserAuthRepositoryAsync and IAuthRepositoryAsync, or will this be taken care of automatically, since one is a subclass (sub-interface?) of the other?

ServiceStack will use the most useful feature that is implemented by Auth Providers, but it only resolves the Auth Provider using either AppHost.GetAuthRepository() and AppHost.GetAuthRepositoryAsync() methods which looks for dependencies registered with either IAuthRepository or IAuthRepositoryAsync.

After it resolves the Auth Provider it will check to see if it implements IUserAuthRepository/Async or IManageRoles/Async to access any enhanced functionality.

1 Like

When you say “in the next version”, do you mean a fix on MyGet/Feedz, or more like the next official version on Nuget in a month or two?

AdminUsersFeature has already been updated that’s now available in Pre Release packages.