Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "arnoldkesselaar"

Hi Everyone,

I am utilising the "multi-tenant, multi-db" scenario.

Consider the following function.

#1 The line with UserManager.ConfirmEmailAsync will not work without the using statement above it. It can't find the correct tenanted user.

#2 The line with await UserManager.UpdateAsync(user) doesn't work without the UnitOfWorkManager.Current.SetTenantId using statement above it.

I would have thought that #2 being within the scope of #1 would be ok without the extra using statement. Why do I need to do this?

[AbpAllowAnonymous]
        [UnitOfWork]
        public async Task<SecureUserResultDto> ActivateUser(SecureUserDto userDto)
        {
            var activationResult = new SecureUserResultDto();

            var user = await GetTenantedUser(userDto.UserEmail);

            if (user != null)
            {
                using (AbpSession.Use(user.TenantId, user.Id))
                {
                    var result = await UserManager.ConfirmEmailAsync(user, userDto.SecurityToken);
                    if (result.Succeeded)
                    {
                        user.IsEmailConfirmed = true;
                        user.IsActive = true;
                        user.Password = HashUserPassword(user, userDto.Password);

                        try
                        {
                            using (UnitOfWorkManager.Current.SetTenantId(user.TenantId))
                                await UserManager.UpdateAsync(user);

                            activationResult.Success = true;
                            activationResult.UserEmail = user.EmailAddress;
                        }
                        catch (Exception e)
                        {
                            activationResult.Errors = new List<string>();
                            activationResult.Errors.Add(e.Message);
                        }

Hello, great system, thanks for building it!

As mentioned in the subject, we have setup a multi-tenant/multi-database scenario. I am also utilising the AngularJS front end to access the .NET CORE 1.1 API. I am using the "Abp.TenantId" to indicate to the back end api the tenant I wish to act in.

Here is my problem scenario: I have 2 "admin" users who can create other users. Each admin user belongs to a separate tenant. If I login as the admin user for t1 and create a user, that user has a tenant id of "1" (correct). Ok, now, I logout and then login to t2 (second tenant). I create a user for that tenant and the tenant id in the database is still "1"! The record is in the t2 database, which is even more strange....

Can anyone shed some light on this? If I shutdown the api and my browser, then login as t2 admin, the correct "TenantId" value is used.

Thanks for your help, Arnold.

Are tenant users stored in the host database?

Showing 1 to 3 of 3 entries