Comments (4)
Hi @ccnicholls99,
If your think this though you will see that you can inject the users ID via the constructor of your implementation of your ITenantChangeService
.
from authpermissions.aspnetcore.
Hi @ccnicholls99,
If your think this though you will see that you can inject the users ID via the constructor of your implementation of your
ITenantChangeService
.
That was the first thing I tried. Unfortunately, at the point where the Tenant is created, you don't yet have access to the User for whom you are creating the Tenant.
See AuthPermissions.SupportCode.AddUsersServices.SignInAndCreateTenant.SignUpNewTenantWithVersionAsync()...
- The Tenant is created first. The TenantChangeService is invoked during this call.
- At this point, the owning AuthUser has not been created
...so injecting UserId yields null (or Non-Tenanted Admin if tenant is being created by an admin).
At the moment, I am working around this by updating any created assets manually, after the tenant is created. Not a deal breaker but another code dependency where I have to make sure the code gets updated in two places instead of one.
IMHO, it would be preferable if SignUpNewTenantWithVersionAsync deferred the call to the TenantChangeService until AFTER both the tenant and owning Auth User are created.
from authpermissions.aspnetcore.
Hi @ccnicholls99,
OK, I can think of two ways to do this with the ISignInAndCreateTenant
service:
- The simplest approach is to log the user's Email and and the Tenant's name via the two DTO classes once the
SignUpNewTenantWithVersionAsync
have finished successfully. - If you need more info, such as the user's ID, then after the
SignUpNewTenantWithVersionAsync
has finished successfully, then the new user has been registered. You can get user's email from theAddNewUserDto
class. You can get that user via theIAuthUsersAdminService
'sFindAuthUserByEmailAsync
method and the tenant name via theAddNewTenantDto
andIAuthTenantAdminService
'sQueryTenants
, which returns aIQueryable<Tenant>
result.
Remember, you can always wrap a service with your own service, or build your own version of a service and use that instead (but in the case of the SignInAndCreateTenant
I don't suggest building your code!)
PS. The ISignInAndCreateTenant
service doesn't setup the user until the tenant has been successfully created. This is done so that if there is a problem, then the user can try again. NOTE: The SignInAndCreateTenant
class has LOT of code to undo things if things goes wrong, especially with sharding multi-tenant app, but even then there can problems.
from authpermissions.aspnetcore.
Related Issues (20)
- Logical problem with IDisableJwtRefreshToken HOT 7
- Is there any way to add a user in multiple tenants with different levels of permissions in each tenant? HOT 1
- Can this library work with microservice based solution HOT 1
- Error localization / translation feature request HOT 14
- Create a demo using JWT and Cookie both HOT 1
- Startup failing with EF Core 7 HOT 3
- User who has rights in several tenants HOT 3
- Invite user that already invited on another tenant by same email Id. HOT 1
- AddSingleTenantReadWriteQueryFilter for Entity type hierarchy HOT 6
- Potential error in Wiki for Setup Authentication HOT 1
- SQLite and GRPC HOT 14
- .net 7 Error Sharding Example HOT 1
- SigningKey Property on AuthPJwtConfiguration doesn't support keys generated as byte[] HOT 4
- AuthP support for UserNames? HOT 4
- API using AuthP and AzureAd Token HOT 1
- Some claim changes ignored until logout/login HOT 3
- ShardingServices - value cannot be null due to update to 5.0.1 HOT 6
- User access in multiple tenants HOT 4
- Support .NET 8 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from authpermissions.aspnetcore.