Open Closed

Switching-Tenants-when-switching-tenants-the-cookie-is-retrieving-the-deleted-tenant-ID-with-the-same-tenant-name #6826


User avatar
0
vipulbuoyancy created
  • ABP Framework version: v7.4.0
  • UI Type: Angular
  • Database System: EF Core (SQL Server)
  • Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

I deleted the tenant and created it again with the same name, I added the admin and another user to the new one, but when clicking switch tenant and entering the name, the tenant_ID that is retrieved in the cookie is the one of the deleted account which doesn’t have the employees trying to login it won’t allow them to login. I tried clearing cookies, force refresh, didn’t help, once you enter the tenant name, it retrieved the ID of the deleted one.

I try this code but it's not work

Configure<AbpAspNetCoreMultiTenancyOptions>(options =>
{
    options.MultiTenancyMiddlewareErrorPageBuilder = async (httpContext, exception) =>
    {
        foreach (var cookie in httpContext.Request.Cookies)
        {
            httpContext.Response.Cookies.Delete(cookie.Key);
        }
        httpContext.Response.Redirect(httpContext.Request.Path);
        return true;
    };
});

Please help to resolve this.

Thanks


5 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Could you share the full steps to reproduce the problem? thanks.

  • User Avatar
    0
    vipulbuoyancy created

    Hi,

    Thank you for support. I shared steps to reproduce:

    • I created new tenant "ABCD" and login with default tenant's admin
    • I deleted the tenant "ABCD" and re-create new tenant with same name "ABCD"
    • I try to login with tenant "ABCD" but when clicking switch tenant and entering the name, the tenant_ID that is retrieved in the cookie is the one of the deleted account which doesn’t have the users trying to login it won’t allow them to login

    Thank you

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    It works for me:

    You can see the video https://drive.google.com/file/d/10APitqORLwtrMYb7MAo4J8W-XWsMmxYg/view?usp=sharing

    Configure<AbpAspNetCoreMultiTenancyOptions>(options =>
    {
        options.MultiTenancyMiddlewareErrorPageBuilder = async (httpContext, exception) =>
        {
            foreach (var cookie in httpContext.Request.Cookies)
            {
                httpContext.Response.Cookies.Delete(cookie.Key);
            }
            httpContext.Response.Redirect(httpContext.Request.GetEncodedPathAndQuery());
            return true;
        };
    });
    
  • User Avatar
    0
    vipulbuoyancy created

    Hi

    It's not working for me this code

    Configure<AbpAspNetCoreMultiTenancyOptions>(options =>
    {
        options.MultiTenancyMiddlewareErrorPageBuilder = async (httpContext, exception) =>
        {
            foreach (var cookie in httpContext.Request.Cookies)
            {
                httpContext.Response.Cookies.Delete(cookie.Key);
            }
            httpContext.Response.Redirect(httpContext.Request.GetEncodedPathAndQuery());
            return true;
        };
    });
    

    I have follow all steps from your video. thank you

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Could you share a simple project via email that can reproduce the problem with me? I will check it. shiwei.liang@volosoft.com

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11