Base solution for your next web application
Open Closed

Login with tenant problem on production server #10249


User avatar
0
novacon created

Hi there,

We have a tenant login problem on production server. In login page when I try to switch tenant and enter a name, page is refreshing with no errors and tenant is not chosen. Also in admin page, in customers section, when I click "Login as this tenant", page refreshes and gives javascript alert "InternalServerError" on /api/TokenAuth/ImpersonatedAuthenticate?impersonationToken=2d09bbf4-09d1-45e3-bda5-4292ee677dc7&d=1618502794115. There is no problem in development - local environment so I cannot debug and solve the error, but when we deploy the project on server, which is ubuntu 18.04, we're encountering this problem.

product version : 9.3.0
product type: angular
product framework type: .net core

6 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    By default, AspNet Zero uses the header name "Abp.TenantId". You can either change it in your app or disable it in nginx, see http://nginx.org/en/docs/http/ngx_http_core_module.html#ignore_invalid_headers. To change it in your app, search for "Abp.TenantId" and change its value. Also change it in your module as shown below;

    Configuration.MultiTenancy.TenantIdResolveKey = "Abp-TenantId";
    

    If this doesn't work, please check the server side log file (Logs.txt) to see the error details.

  • User Avatar
    0
    novacon created

    Hi,

    I changed the TenantResolveKey and replace all Abp.TenantId with Abp-TenantId as you suggested, but no success. Here are the error logs for the error.

    Mvc.ExceptionHandling.AbpExceptionFilter - Current tenant is different than given tenant. AbpSession.TenantId: , given tenantId: 2 System.Exception: Current tenant is different than given tenant. AbpSession.TenantId: , given tenantId: 2 at Fiorent.Authorization.Impersonation.ImpersonationManager.CheckCurrentTenant(Nullable`1 tenantId) in /var/www/fiorent-app/aspnet-core/src/Fiorent.Core/Authorization/Impersonation/ImpersonationManager.cs:line 115 at Fiorent.Authorization.Impersonation.ImpersonationManager.GetImpersonatedUserAndIdentity(String impersonationToken) in /var/www/fiorent-app/aspnet-core/src/Fiorent.Core/Authorization/Impersonation/ImpersonationManager.cs:line 45 at Fiorent.Web.Controllers.TokenAuthController.ImpersonatedAuthenticate(String impersonationToken) in /var/www/fiorent-app/aspnet-core/src/Fiorent.Web.Core/Controllers/TokenAuthController.cs:line 347 at lambda_method(Closure , Object )

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @novacon

    Did you also changed https://github.com/aspnetzero/aspnet-zero-core/blob/dev/angular/src/assets/abp-web-resources/abp.js#L30 ? If so, could you share your app's URL with [email protected] ?

    Thanks,

  • User Avatar
    0
    novacon created

    Yes I've changed the abp.js also.

    I sent app's url to [email protected]

  • User Avatar
    0
    mdepouw created

    Hello - we're having the same problem, what was the fix? thanks!

  • User Avatar
    0
    mdepouw created

    FIX:

    in angular/src/assets/abp-web-resources/abp.js abp.multiTenancy.tenantIdCookieName = 'Abp-TenantId';

    in aspnet-core/src/Blah.Core/AccountCoreModule.cs Configuration.MultiTenancy.TenantIdResolveKey = "Abp-TenantId";