Skip to content
This repository has been archived by the owner on Dec 20, 2018. It is now read-only.

Replace a Role Validator #2080

Closed
mmillican opened this issue Nov 21, 2018 · 2 comments
Closed

Replace a Role Validator #2080

mmillican opened this issue Nov 21, 2018 · 2 comments

Comments

@mmillican
Copy link

mmillican commented Nov 21, 2018

I am trying to create a custom role validator to support pseudo-multi-tenancy (which I know is not officially supported in Identity) and am running into some issues.

I've verified that my validator does work and is being called. However, the default validator appears to be called also.

Here's my Identity service registration

services.AddIdentity<User, Role>(setup =>
    {
        // Redacted settings
    })
    .AddRoleValidator<CustomRoleValidator<Role>>()
    .AddEntityFrameworkStores<ApplicationDbContext>()
    .AddDefaultTokenProviders();

How can I remove the default RoleValidator?

@HaoK
Copy link
Member

HaoK commented Nov 21, 2018

If you add a IRoleValidator<Role> before calling AddIdentity, it should skip adding the default one. Alternatively i believe you can remove service registrations directly as well, but try adding yours first

@mmillican
Copy link
Author

Thanks @HaoK! That did the trick.

I also had to change the unique index on the Roles table as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants