Skip to content

Commit 2ded140

Browse files
committed
fix - tenant null check
1 parent 2c88cfc commit 2ded140

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/Infrastructure/Services/General/TenantService.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ public TenantService(IOptions<MultitenancySettings> options, IHttpContextAccesso
6969
private void SetTenant(string tenantKey)
7070
{
7171
var tenant = _context.Tenants.Where(a => a.Key == tenantKey).FirstOrDefaultAsync().Result;
72+
73+
if (tenant == null)
74+
{
75+
throw new InvalidTenantException(_localizer["tenant.invalid"]);
76+
}
77+
7278
if (tenant.Key != MultitenancyConstants.Root.Key)
7379
{
7480
if (!tenant.IsActive)
@@ -83,11 +89,6 @@ private void SetTenant(string tenantKey)
8389
}
8490

8591
_currentTenant = _mapper.Map<TenantDto>(tenant);
86-
if (_currentTenant == null)
87-
{
88-
throw new InvalidTenantException(_localizer["tenant.invalid"]);
89-
}
90-
9192
if (string.IsNullOrEmpty(_currentTenant.ConnectionString))
9293
{
9394
SetDefaultConnectionStringToCurrentTenant();

0 commit comments

Comments
 (0)