Skip to content

Commit d8abaa9

Browse files
committed
Remove tenant name claim - Example7
1 parent d396d00 commit d8abaa9

File tree

5 files changed

+6
-5
lines changed

5 files changed

+6
-5
lines changed

Example7.MvcWebApp.ShardingOnly/Controllers/HomeController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
using Example7.MvcWebApp.ShardingOnly.PermissionsCode;
99
using Microsoft.AspNetCore.Mvc;
1010
using Microsoft.AspNetCore.Authorization;
11-
using System.Drawing;
1211
using AuthPermissions.AspNetCore.ShardingServices;
12+
using AuthPermissions.BaseCode.PermissionsCode;
1313

1414
namespace Example7.MvcWebApp.ShardingOnly.Controllers
1515
{
@@ -26,7 +26,7 @@ public IActionResult Index(string message)
2626
{
2727
ViewBag.Message = message;
2828

29-
if (AddTenantNameClaim.GetTenantNameFromUser(User) == null)
29+
if (User.Claims.All(x => x.Type != PermissionConstants.DataKeyClaimType))
3030
return View(new AppSummary());
3131

3232
return RedirectToAction("Index", "Invoice");
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"Cache": {
33
"ShardingEntry-Tenant_1": "{\r\n \"Name\": \"Tenant_1\",\r\n \"DatabaseName\": \"Tenant_1\",\r\n \"ConnectionName\": \"EastCoastServer\",\r\n \"DatabaseType\": \"SqlServer\"\r\n}",
4-
"ShardingEntry-Extra tenant-20230808101149": "{\r\n \"Name\": \"Extra tenant-20230808101149\",\r\n \"DatabaseName\": \"20230808101149-892\",\r\n \"ConnectionName\": \"CentralServer\",\r\n \"DatabaseType\": \"SqlServer\"\r\n}"
4+
"ShardingEntry-Extra tenant-20230808101149": "{\r\n \"Name\": \"Extra tenant-20230808101149\",\r\n \"DatabaseName\": \"20230808101149-892\",\r\n \"ConnectionName\": \"CentralServer\",\r\n \"DatabaseType\": \"SqlServer\"\r\n}",
5+
"ShardingEntry-SignOn-20240111091446-697": "{\r\n \"Name\": \"SignOn-20240111091446-697\",\r\n \"DatabaseName\": \"Db-20240111091446-697\",\r\n \"ConnectionName\": \"CentralServer\",\r\n \"DatabaseType\": \"SqlServer\"\r\n}"
56
},
67
"TimeOuts": {}
78
}

Example7.MvcWebApp.ShardingOnly/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
//AuthP version 5 and above: Use this method to configure sharding
5353
.SetupMultiTenantSharding(new ShardingEntryOptions(false))
5454
.IndividualAccountsAuthentication()
55-
.RegisterAddClaimToUser<AddTenantNameClaim>()
5655
.RegisterTenantChangeService<ShardingOnlyTenantChangeService>()
5756
.AddRolesPermissionsIfEmpty(Example7AppAuthSetupData.RolesDefinition)
5857
.AddAuthUsersIfEmpty(Example7AppAuthSetupData.UsersRolesDefinition)

Example7.MvcWebApp.ShardingOnly/Views/Shared/_CompanyLayout.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<head>
77
<meta charset="utf-8" />
88
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
9-
<title>@ViewData["Title"] - @AddTenantNameClaim.GetTenantNameFromUser(User)</title>
9+
@* <title>@ViewData["Title"] - @AddTenantNameClaim.GetTenantNameFromUser(User)</title> *@
1010
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
1111
<link rel="stylesheet" href="~/css/site.css" />
1212
</head>

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The AuthP is an open-source library under the MIT licence (and remain as a open-
1010

1111
If you have already built your application using an older version, then you need to look at the following "how up update" documents
1212

13+
- From Migrating from AuthPermissions.AspNetCore 3, 4, 5 to 6.1 see [UpdateToVersion620.md](https://github.com/JonPSmith/AuthPermissions.AspNetCore/blob/main/UpdateToVersion620.md). NOTE: you only need to do this if you are using the "Sign up for a new tenant, with versioning" (shortened to "Sign up Tenant") feature **AND** your multi-tenant uses [sharding](https://github.com/JonPSmith/AuthPermissions.AspNetCore/wiki/Sharding-explained).
1314
- From Migrating from AuthPermissions.AspNetCore 3, 4, 5 to 6.0 see [UpdateToVersion6.md](https://github.com/JonPSmith/AuthPermissions.AspNetCore/blob/main/UpdateToVersion5.md)
1415
- From Migrating from AuthPermissions.AspNetCore 2, 3 or 4.* to 5.0 see [UpdateToVersion5.md](https://github.com/JonPSmith/AuthPermissions.AspNetCore/blob/main/UpdateToVersion5.md)
1516
- From Migrating from AuthPermissions.AspNetCore 2.* to 3.0 see [UpdateToVersion3.md](https://github.com/JonPSmith/AuthPermissions.AspNetCore/blob/main/UpdateToVersion3.md)

0 commit comments

Comments
 (0)