"willignicolas@gmail.com" की गतिविधियाँ

उत्तर

Hello and thanks for your help.

I was not able to make your code working (BTW the last edition of your post doesn't change the value of the claim so i don't anderstand how it work)

There is the code that works (inspired by your first editon of your last post) :

My application service :

[Authorize]
    public class ConfigurationAppService : JureezAppService, IConfigurationAppService
    {
        private readonly ICurrentPrincipalAccessor _currentPrincipalAccessor;
        private readonly VAI.IIdentityUserRepository _userRepository;
        private readonly SignInManager<VAI.IdentityUser> _signInManager;


        public ConfigurationAppService(ICurrentPrincipalAccessor currentPrincipalAccessor,
            VAI.IIdentityUserRepository userRepository,
            SignInManager<VAI.IdentityUser> signInManager)
        {
            _currentPrincipalAccessor = currentPrincipalAccessor;
            _userRepository = userRepository;
            _signInManager = signInManager;
        }

        public virtual ShowPopupsOutputDto GetShowedPopups()
        {
            var welcomePopupClaim = _currentPrincipalAccessor.Principal.Identities.First().FindFirst(ClaimsConst.WelcomePopupShowedClaimName);

            return new ShowPopupsOutputDto
            {
                ShowWelcomeConfigPopup = welcomePopupClaim == null || welcomePopupClaim.Value == "false",
            };
        }

        public virtual async Task SetShowedWelcomePopup()
        {
            var user = await _userRepository.FindAsync(CurrentUser.GetId());

            await _signInManager.SignOutAsync();
            await _signInManager.SignInWithClaimsAsync(user, true, new List<Claim> { new Claim(ClaimsConst.WelcomePopupShowedClaimName, "true") });
        }

    }

No claimprincipalcontributor only the claim declaration in my module :

Configure<AbpClaimsServiceOptions>(options =>
            {
                options.RequestedClaims.Add(ClaimsConst.WelcomePopupShowedClaimName);
            });

With this solution my claim value is truly updated and available on the read method for the rest of my user session.

Thanks again for your time and your help.

Nicolas

उत्तर

Thanks for your quick reply.

I have tested your solution but the result stay the same.

On the end of the write method the CurrentUser.GetAllClaims() (or on the currentPrincipalAccessor.principal) have the claim with the new value ("true") but when i call the read method again the value is "false".

There is my full code of appservice :

public virtual ShowPopupsOutputDto GetShowedPopups()
        {
            var welcomePopupClaim = _currentPrincipalAccessor.Principal.Identities.First().FindFirst(ClaimsConst.WelcomePopupShowedClaimName);

            var test = CurrentUser.GetAllClaims();
            return new ShowPopupsOutputDto
            {
                ShowWelcomeConfigPopup = welcomePopupClaim == null || welcomePopupClaim.Value == "false",
            };

        }

        public virtual async Task SetShowedWelcomePopup()
        {
            var claimsIdentity = _currentPrincipalAccessor.Principal.Identities.First();

            claimsIdentity.AddOrReplace(new Claim(ClaimsConst.WelcomePopupShowedClaimName, "true"));

            using (_currentPrincipalAccessor.Change(_currentPrincipalAccessor.Principal))
            {
                await _httpContextAccessor.HttpContext.SignOutAsync();
                await _httpContextAccessor.HttpContext.SignInAsync(_currentPrincipalAccessor.Principal);
            }
            
            
        }

And the contributor :

  public class JureezClaimsPrincipalContributor : IAbpClaimsPrincipalContributor, ITransientDependency
    {
        public async Task ContributeAsync(AbpClaimsPrincipalContributorContext context)
        {
            var currentTenant = context.ServiceProvider.GetRequiredService<ICurrentTenant>();

            var claimsIdentity = new ClaimsIdentity();
            context.ClaimsPrincipal.Identities.First().AddClaim(new Claim(ClaimsConst.WelcomePopupShowedClaimName, currentTenant.Id != null ? "false" : "true")); ;
        }
    }

Thanks again for your help.

Nicolas.

Hi Alper,

It's ok for us too.

Thanks for your help and the solution.

sended to info@abp.io

Many thanks for your help.

I can do that but you must have the database too. Because it works with a New db. How can we send you our mssql db ? (a Light version that have the problem too)

Same here we use exclusively one shared database.

Thanks Alper to have take time to read the logs.

I don't anderstand when to add a new connection string in my db? I can add it after the tenant creation but it's too late because the user will not be created on the tenant creation and the problem will still remain. I can add it before the tenant creation but I have not the Id at this moment.

Sorry if this a dumb question and i have not anderstand your advised manipulation.

One more information it's that with a completly new db in my existing migrated app when i create a new tenant the user is created with success and the SaasTenantConnectionStrings is empty.

Hello Alper,

There is the situation. I have a few days ago pass to 4.3 (without making the migration with compare files method) launch the DBMigrator and see the tenant creation problem in production.

Then I have make the full migration with compare files, restart DBMigrator and still have the problem.

The Handler is in place and the error in the log is from the handler file.

More informations : Tenant creation is OK with new project and with our project but a new database so is something in our database.

Many thanks for your help.

The error log on tenant creation (we transfer link because is too long for the post permission) https://we.tl/t-BLS8bFoK4s

Thanks for this information Alper. This can be closed.

उत्तर

Hello Alper,

Sorry to come back with this but we still couldn't create a new tenant and use them because the user is not created. There are several of us in this situation since switching to 4.3 and this is a major problem for us because we can no longer have a new customer ...

I tested that on a new 4.3 project the problem does not appear, yet we did the migration well (via file comparison) but impossible to have a user on the creation of a new tenant.

The situation is becoming critical for us. Thank you in advance for your precious help.

Nicolas.

31 प्रविष्टियों में 11 से 20 दिखा रहा है
Made with ❤️ on ABP v8.2.0-preview Updated on मार्च 25, 2024, 15:11