Brief: I'm facing a problem with setting Global Query Filter using Claim added to signed user.
Error scenario: when signing in ef core is still not loaded so
Код: Выделить всё
OnModelCreatingКод: Выделить всё
private long GetRequestTenantId()
{
try
{
var tenantClaim = contextAccessor.HttpContext.User.Claims.Where(c => c.Type == "TenantId").FirstOrDefault();
if (tenantClaim == null)
return 0;
bool IsParsed = long.TryParse(tenantClaim.Value, out long tenantId);
if (!IsParsed)
return 0;
return tenantId;
}
catch (Exception ex)
{
return 0;
}
}
Код: Выделить всё
0Is there any other way to set Global Query Filter to fix this problem?
What I tried to do was set query filter according to the user that sent the request.
which works fine when I relaunch the application and happens again when the session ends and I log in again.
Edit: My query filter is TenantId.
Источник: https://stackoverflow.com/questions/781 ... -ef-core-6
Мобильная версия