You have entered the account and password to log in.
The ICurrentTenant cannot obtain the tenant ID before the /connect/token interface.
2 Answer(s)
-
0
Before a user is authenticated and a token is issued (i.e., before the
/connect/token
endpoint is called), the ABP Framework resolves the current tenant using tenant resolvers (such as domain, header, cookie, or query string). However, theICurrentTenant.Id
will only be set if the tenant can be resolved from the incoming request.During the login process (before the token is issued), if the request does not contain sufficient tenant information (for example, the
__tenant
header, a tenant-specific subdomain, or a query string parameter),ICurrentTenant.Id
will be null. This is by design: the tenant context is established based on the request, not the user credentials.To ensure
ICurrentTenant
is set before authentication, you must configure and use a tenant resolver that can extract the tenant from the request (such as domain/subdomain, header, or query string). For example, in a multi-tenant Angular app, the frontend should send the__tenant
header or use a tenant-specific subdomain.If you need to access tenant information during the login process, make sure your frontend provides the tenant identifier in the request, and your backend is configured to resolve it.
Example configuration:
Configure<AbpTenantResolveOptions>(options => { options.AddDomainTenantResolver("{0}.yourdomain.com"); options.AddHeaderTenantResolver(); options.AddCookieTenantResolver(); options.AddQueryStringTenantResolver(); });
- If the tenant cannot be resolved from the request,
ICurrentTenant.Id
will remain null until after the user is authenticated and the token is issued.
Sources:
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
-
0