Skip to content

Error when resetting password for tenant admin in host context #22916

Open
@mahmut-gundogdu

Description

@mahmut-gundogdu

Is there an existing issue for this?

  • I have searched the existing issues

Description

By default tenant's first user is admin on my system.

When the user is a host (no tenant selected and has a specific role), the middleware executes dataFilter.Disable<IMultiTenant>();, allowing access to all data. However, when using the "Set Password" modal on the identity/users page to reset the password for a tenant admin, I encounter the following error:

Error: "Username 'admin' is already taken."

Request URL:
api/identity/users/3a161345-51cd-fb9c-2d79-d0f77090af2e/change-password

Response:

{
    "error": {
        "code": "Volo.Abp.Identity:DuplicateUserName",
        "message": "Username 'admin' is already taken.",
        "details": null,
        "data": {
            "0": "admin"
        },
        "validationErrors": null
    }
}

Additional Context:

  • The issue occurs when the IMultiTenant filter is disabled (conditionally) , suggesting a possible conflict in username validation across tenants.
Image

the middleware

public class MultiTenancyFilterMiddleware
{
// ... removed  some code for brevity

 public async Task InvokeAsync(HttpContext context, IDataFilter dataFilter, ICurrentUser currentUser, ICurrentTenant currentTenant)
    {
        var shouldDisableMultiTenancy =  currentUser.IsAuthenticated && currentUser.TenantId == null
            && currentUser.Roles.Any(role => role.ToLower() == RequiredRole);

        if (shouldDisableMultiTenancy)
            dataFilter.Disable<IMultiTenant>();
        else
            dataFilter.Enable<IMultiTenant>();
        
        await _next(context);
    }
}

Reproduction Steps

Steps to Reproduce:

  1. Log in as a host user with a role that disables the IMultiTenant filter.
  2. Navigate to the identity/users page.
  3. Attempt to reset the password for a tenant admin using the "Set Password" modal.

Expected behavior

The password reset should complete successfully without a duplicate username error.

Actual behavior

The system throws a "Username 'admin' is already taken" error.

Regression?

No response

Known Workarounds

No response

Version

8.3.0

User Interface

Angular

Database Provider

EF Core (Default)

Tiered or separate authentication server

None (Default)

Operation System

macOS

Other information

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions