Skip to content

Commit 58ad002

Browse files
committed
Merge branch 'dev'
2 parents 57fc90c + a950b85 commit 58ad002

4 files changed

Lines changed: 18 additions & 19 deletions

File tree

AuthPermissions.AspNetCore/CreateNuGetRelease.nuspec

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata>
44
<id>AuthPermissions.AspNetCore</id>
5-
<version>2.3.0</version>
5+
<version>2.3.1</version>
66
<authors>Jon P Smith</authors>
77
<product>AuthPermissions.AspNetCore</product>
88
<copyright>Copyright (c) 2021 Jon P Smith</copyright>
99
<description>Provides extra authorization and multi-tenant features to a ASP.NET Core application.</description>
1010
<releaseNotes>
11-
- New Feature: You can add extra claims to the user via the RegisterAddClaimToUser method
12-
- New Feature: Tap into AuthPermissionsDbContext events by registering a service implmenting the IRegisterStateChangeEvent interface
13-
- Bug Fix: UpdateRoleToPermissionsAsync now return errors if a Role change is invalid for a user or tenants that is that Role - see issue #13
14-
- Bug Fix: DeleteRoleAsync now handles tenant Roles - see issue #13
15-
- Bug Fix: Add or update of an AuthUser now checks the tenant has the correct Roles - see issue #15
11+
Bug Fix: Problem in ClaimCalculator when used with multi-tenant applications - see issue #23
1612
</releaseNotes>
1713
<license type="expression">MIT</license>
1814
<projectUrl>https://github.com/JonPSmith/AuthPermissions.AspNetCore</projectUrl>

AuthPermissions.AspNetCore/MultiProjPack.xml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@
44
<!-- See documentation for all the possible values -->
55
<metadata>
66
<id>AuthPermissions.AspNetCore</id>
7-
<version>2.3.0</version>
7+
<version>2.3.1</version>
88
<authors>Jon P Smith</authors>
99
<product>AuthPermissions.AspNetCore</product>
1010
<copyright>Copyright (c) 2021 Jon P Smith</copyright>
1111
<description>Provides extra authorization and multi-tenant features to a ASP.NET Core application.</description>
1212
<releaseNotes>
13-
- New Feature: You can add extra claims to the user via the RegisterAddClaimToUser method
14-
- New Feature: Tap into AuthPermissionsDbContext events by registering a service implmenting the IRegisterStateChangeEvent interface
15-
- Bug Fix: UpdateRoleToPermissionsAsync now return errors if a Role change is invalid for a user or tenants that is that Role - see issue #13
16-
- Bug Fix: DeleteRoleAsync now handles tenant Roles - see issue #13
17-
- Bug Fix: Add or update of an AuthUser now checks the tenant has the correct Roles - see issue #15
13+
Bug Fix: Problem in ClaimCalculator when used with multi-tenant applications - see issue #23
1814
</releaseNotes>
1915
<license type="expression">MIT</license>
2016
<projectUrl>https://github.com/JonPSmith/AuthPermissions.AspNetCore</projectUrl>

AuthPermissions/ClaimsCalculator.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff 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())

ReleaseNotes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release Notes
22

3+
## 2.3.1
4+
5+
- Bug Fix: Problem in ClaimCalculator when used with multi-tenant applications - see issue #23
6+
37
## 2.3.0
48

59
- New Feature: You can add extra claims to the user via the RegisterAddClaimToUser method

0 commit comments

Comments
 (0)