Open Closed

Need to login to the portal even after the tenant activation end date is completed #7373


User avatar
0
oncalldev@cloudassert.com created
  • ABP Framework version: v8.0.1
  • UI Type: Angular
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

we have set activation state as 1(active with limited time), and we set activation end date, Even after the completion of activation end date, we need the users of the tenant to be logged into the portal with limited permission Ex: In the below image, the activation end date(2024-06-03 23:59:59.0000000) is a past date, When the user of this tenant tries to login to the portal now(today:2024-06-19 23:59:59.0000000 ), it is not allowing to login, But it should allow to login and only one page should be visible to the user What should we do to fix this?


9 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    This behavior is by design.

    Need to login to the portal even after the tenant activation end date is completed

    activation status will be meaningless if you allow users under the tenant to log in.

  • User Avatar
    0
    oncalldev@cloudassert.com created

    This is business requirement : Even after the subscription ends, The admin should access the portal and only one page should be visible(payment page). We have added subscription expiry date in tenant activation end date column. Is there any chance to handle this by overriding any methods?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The IsActiveAsync of TenantManager.

  • User Avatar
    0
    oncalldev@cloudassert.com created

    I have tried the above given code by creating a new file and inherited the Tenantmanager . But that didn't work. I have added the code below. But when I tried overriding the createasync function, it worked, But the IsActiveAsync is not working. I cannot able to login a user who's subscription is ended(tenant activation end date is past date ).

    I have followed this link for creating a custom tenantmanager file(https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Overriding-Services#example-overriding-a-domain-service)

    using System;
    using System.Threading.Tasks;
    using Volo.Abp.DependencyInjection;
    using Volo.Saas;
    using Volo.Saas.Tenants;
    
    namespace WDN.HealthySmiles.Tenants
    {
        [Dependency(ReplaceServices = true)]
        [ExposeServices(typeof(TenantManager))]
        public class CustomTenantManager : TenantManager
        {
            public CustomTenantManager(ITenantRepository tenantRepository) : base(tenantRepository)
            {
            }
            public virtual Task<bool> IsActiveAsyc(Tenant tenant)
            {
                return Task.FromResult(tenant.ActivationState switch
                {
                    TenantActivationState.Active => true,
                    TenantActivationState.Passive => true,
                    TenantActivationState.ActiveWithLimitedTime => true,
                    _ => true
                });
            }
            [Obsolete("Use IsActiveAsync method.")]
            public bool IsActive(Tenant tenant)
            {
                return tenant.ActivationState switch
                {
                    TenantActivationState.Active => true,
                    TenantActivationState.Passive => true,
                    TenantActivationState.ActiveWithLimitedTime => true,
                    _ => true
                };
            }
    
            public override  Task<Tenant> CreateAsync(string name, Guid? editionId = null)
            {
                return base.CreateAsync(name, editionId);
            }
        }
    }
    

    I have added this code in the Domain layer . And also tried by adding [Dependency(ReplaceServices = true)] [ExposeServices(typeof(TenantManager))] and removing these lines based on the given lines in the above link (ExposeServices(typeof(IdentityUserManager))] attribute is required here since IdentityUserManager does not define an interface (like IIdentityUserManager) )

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share the logs?

    Set log level to Debug.

    public class Program
    {
        public async static Task<int> Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                .MinimumLevel.Debug()
                .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
                .Enrich.FromLogContext()
                .WriteTo.Async(c => c.File("Logs/logs.txt"))
                .WriteTo.Async(c => c.Console())
                .CreateLogger();
    
  • User Avatar
    0
    oncalldev@cloudassert.com created

    Hi,please find the gdrive link below https://drive.google.com/file/d/1sRQyvGgz3ocNrri2X_tlqIsEUVlZIWiL/view?usp=drive_link

    I have shared a image of logs, It has thrown business exception. The tenant id shared in the details line is the one which I tried to login.

    for setting the logs, the below code has been used

    public class Program
    {
        public async static Task<int> Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
    #if DEBUG
                .MinimumLevel.Debug()
    #else
                .MinimumLevel.Information()
    #endif
                .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
                .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
                .Enrich.FromLogContext()
                .WriteTo.Async(c => c.File("Logs/logs.txt", rollOnFileSizeLimit: true, fileSizeLimitBytes: 10485760, retainedFileCountLimit: 100))
                .WriteTo.Async(c => c.Console())
                .CreateLogger();
    

    Please let me know if you cannot access logs file

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Please try to expose the ITenantManager as well.

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(TenantManager), typeof(ITenantManager))]
    public class CustomTenantManager : TenantManager
    

  • User Avatar
    0
    oncalldev@cloudassert.com created

    Hi, Tried adding ITenantManager in expose services, but that didn't work. Getting the same exception in authserver logs I have attached the CustomTenantManager code below

    namespace WDN.HealthySmiles.Tenants
    {
        [Dependency(ReplaceServices = true)]
        [ExposeServices(typeof(TenantManager), typeof(ITenantManager))]
        public class CustomTenantManager : TenantManager
        {
            public CustomTenantManager(ITenantRepository tenantRepository) : base(tenantRepository)
            {
            }
            public virtual Task<bool> IsActiveAsyc(Tenant tenant)
            {
                return Task.FromResult(tenant.ActivationState switch
                {
                    TenantActivationState.Active => true,
                    TenantActivationState.Passive => true,
                    TenantActivationState.ActiveWithLimitedTime => true,
                    _ => true
                });
            }
            [Obsolete("Use IsActiveAsync method.")]
            public bool IsActive(Tenant tenant)
            {
                return tenant.ActivationState switch
                {
                    TenantActivationState.Active => true,
                    TenantActivationState.Passive => true,
                    TenantActivationState.ActiveWithLimitedTime => true,
                    _ => true
                };
            }
            public override Task<Tenant> CreateAsync(string name, Guid? editionId = null)
            {
                return base.CreateAsync(name, editionId);
            }
        }
    }
    

    And also tried by adding the CustomTenantManager in expose service( * [ExposeServices(typeof(TenantManager), typeof(ITenantManager), typeof(CustomTenantManager))]* ), But this also not worked.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share a simple project to reproduce this?

    liming.ma@volosoft.com

    Thanks.

Made with ❤️ on ABP v9.0.0-preview Updated on July 18, 2024, 06:07