File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,21 +77,24 @@ public async Task<List<Claim>> GetClaimsForAuthUserAsync(string userId)
7777 private async Task<string> CalcPermissionsForUserAsync(string userId)
7878 {
7979 //This gets all the permissions, with a distinct to remove duplicates
80- var permissionsForAllRoles = (await _context.UserToRoles.Where(x => x.UserId == userId)
80+ var permissionsForAllRoles = await _context.UserToRoles
81+ .Where(x => x.UserId == userId)
8182 .Select(x => x.Role.PackedPermissionsInRole)
82- .ToListAsync()) ;
83+ .ToListAsync();
8384
8485 if (_options.TenantType != TenantTypes.NotUsingTenants)
8586 {
8687 //We need to add any RoleTypes.TenantAdminAdd for a tenant user
8788
88- var autoAddRoles = await _context.AuthUsers
89+ var autoAddPermissions = await _context.AuthUsers
8990 .Where(x => x.UserId == userId && x.TenantId != null)
90- .Select(x => x.UserTenant.TenantRoles.Where(y => y.RoleType == RoleTypes.TenantAutoAdd))
91- .SingleOrDefaultAsync();
91+ .SelectMany(x => x.UserTenant.TenantRoles
92+ .Where(y => y.RoleType == RoleTypes.TenantAutoAdd)
93+ .Select(z => z.PackedPermissionsInRole))
94+ .ToListAsync();
9295
93- if (autoAddRoles != null )
94- permissionsForAllRoles.AddRange(autoAddRoles.Select(x => x.PackedPermissionsInRole) );
96+ if (autoAddPermissions.Any() )
97+ permissionsForAllRoles.AddRange(autoAddPermissions );
9598 }
9699
97100 if (!permissionsForAllRoles.Any())
You can’t perform that action at this time.
0 commit comments