|
1 | 1 | # Upgrade to the SignInAndCreateTenant service - version 6.2.0
|
2 | 2 |
|
3 |
| -AuthP version 6.2.0 has a **BREAKING CHANGE** around the `SignInAndCreateTenant` ??????????????????????? |
| 3 | +AuthP version 6.2.0 has a **BREAKING CHANGE**, but **ONLY** 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). Otherwise you can ignore this breaking change. |
4 | 4 |
|
5 |
| -## Why I changed the SignInAndCreateTenant service |
| 5 | +The information on updated "Sign up Tenant" feature can be found at: |
6 | 6 |
|
7 |
| -The AuthP library has a service called `SignInAndCreateTenant` which a new user can log in and obtain a new tenant (see the [“Multi-tenant apps with different versions can increase your profits”](https://www.thereformedprogrammer.net/multi-tenant-apps-with-different-versions-can-increase-your-profits/) article for more on this). The current (6.1.0) AuthP version of the `SignInAndCreateTenant` service will try to “undo” the sign up for a tenant so that the user can again but has the following issues. |
| 7 | +- [Sign up for a new tenant, with versioning](https://github.com/JonPSmith/AuthPermissions.AspNetCore/wiki/Sign-up-for-a-new-tenant%2C-with-versioning) page in the documentation. |
| 8 | +- [Multi-tenant apps with different versions can increase your profits](https://www.thereformedprogrammer.net/multi-tenant-apps-with-different-versions-can-increase-your-profits/) article in my tech blog. |
8 | 9 |
|
9 |
| -- You can’t always undo a new tenant, which means the new user can’t use the multi-tenant app. |
10 |
| -- When an Exception occurs its not logged, which makes it to |
11 |
| -- The “undo” feature code very complex and uses direct access to the tenant instead of using the AuthTenantAdminService service. |
| 10 | +## What changes do I you need to do my existing app? |
12 | 11 |
|
13 |
| -Therefore I have created a new `SignInAndCreateTenant` service which uses a very different approach to overcome the issues in the 6.1.0 AuthP version. The changes are: |
| 12 | +The the `ISignInAndCreateTenant` hasn't changed, but the `IGetDatabaseForNewTenant` service, which you needed to create if your multi-tenant app is using sharding, is replaced it with the `ISignUpGetShardingEntry` service. If you used `IGetDatabaseForNewTenant`, then you will get a compile error and you need to remove your old `ISignUpGetShardingEntry` service with and create a new service that follows the `IGetDatabaseForNewTenant` interface. |
14 | 13 |
|
15 |
| -- If a fatal error, e.g Exception, occurs: |
16 |
| - 1. They are logged within the application, with a unique name. |
17 |
| - 2. The user is given the error unique name and asked to contact the App's support team. |
18 |
| - 3. A new service is added that allows the support team to create a tenant for a tenant using the version data. |
| 14 | +There are two demo versions in the code before release of version 6.2.0 and they have been updated to the new version. See the updated demos below: |
19 | 15 |
|
20 |
| -The new design won't create a tenant that would stop the user creating the tenant they want because the service uses a temporary name, e.g. "TempSignIn-{tenantId}-{DateTime}" for the tenant and any sharding entry name during setting up the new tenant. Once the process has successfully ended it changes the tenant's name(s) to the name that the user provided. This has two benefits: |
| 16 | +- For hybrid sharding see the [`DemoGetDatabaseForNewTenant`](https://github.com/JonPSmith/AuthPermissions.AspNetCore/blob/main/AuthPermissions.SupportCode/DemoGetDatabaseForNewTenant.cs) for the changes. |
| 17 | +- For sharding-only see the [`DemoShardOnlyGetDatabaseForNewTenant`](https://github.com/JonPSmith/AuthPermissions.AspNetCore/blob/main/AuthPermissions.SupportCode/DemoShardOnlyGetDatabaseForNewTenant.cs) for the changes. |
21 | 18 |
|
22 |
| -- This makes the `SignInAndCreateTenant`'s code much simpler (the original code used direct Auth database accesses rather than the normal services such as `IAuthTenantAdminService` and `IGetSetShardingEntries`). |
23 |
| -- If an fatal error occurs, then the admin user can look for "TempSignIn...", which might help the admin user to see what went wrong. |
| 19 | +## Why I changed the SignInAndCreateTenant service? |
24 | 20 |
|
| 21 | +The original version of the `SignInAndCreateTenant` service will try to “undo” the sign up for a tenant if there is an error. The original would try to delete the tenant so that the new user can try again. Errors are rare in a properly build application, but problem is sometimes the "undo" doesn't work, which can stop the new user from using your multi-tenant application. |
25 | 22 |
|
| 23 | +In the 6.2.0 version of the AuthP library the `SignInAndCreateTenant` service works works in a different way: instead of trying to “undo” things it tells the user to ask your support admin to look at the problem, with a unique string to help the support admin to look what went wrong. |
26 | 24 |
|
| 25 | +The main change is that is uses a unique name (formed from current time) the for the tenant name, tenant database name, etc. and only when the sign up has successfully finished that the correct tenant name. |
| 26 | + |
| 27 | +Other improvements are: |
| 28 | + |
| 29 | +- The original “undo” code was very complex, which makes it hard to cover / test every situations. The new code is much simpler because the unique name makes each "Sign Up" to be different so the new user can again, or talk to your support admin with a reference of what they were trying to do. |
| 30 | +- The original code didn't report `Exception`s properly. The new code logs the Exception with the unique name and send the user a message saying they should contact your support team, with the unique name. This allows your support team to find the Exception log and manually set up the new user. |
| 31 | + |
| 32 | +END |
0 commit comments