Activities of "abhisheksreesaila"

Ok, I found the issue.

---- this code

if (context.Menu.Name == StandardMenus.User || context.Menu.Name == StandardMenus.Shortcut) { var LinkedAccounts = context.Menu.GetMenuItemOrNull("Account.LinkedAccounts"); LinkedAccounts?.RequirePermissions(FinxplorerPermissions.UserMenu.LinkedAccounts); }

was inside if (context.Menu.Name == StandardMenus.Main) { await ConfigureMainMenuAsync(context); }

So it was never called to remove it. now, placed it outside.

got it! let me try that and get back to you!

Thats what i thought. I am not able to find that dependency. Check my screenshots.

Main

Modules

Check the docs before asking a question: https://abp.io/docs/latest Check the samples to see the basic tasks: https://abp.io/docs/latest/samples The exact solution to your question may have been answered before, and please first use the search on the homepage. Provide us with the following info: 🧐 Hint: If you are using the ABP Studio, you can see all the information about your solution from the configuration window, which opens when you right-click on the solution and click on the Solution Configuration button.

  • ABP Framework version: v9.0.3
  • UI Type: Blazor Server
  • Database System: EF Core ( PostgreSQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): No
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Background: I have a following a modular monolith style of developing an application. I have 2 modules apart from Main app.

I am trying to hide the linked accounts, sessions, account delegation etc. Followed the instructions here but did not work. See my screenshots https://abp.io/support/questions/3741/Linked-accounts-in-header-bar

But when i navigate to **session **page - it is not there which is good. Question: Why does it show up when I navigate to other pages + How i can switch it off on all pages?

Code Added

Permissions

Does not hide in the main page

Hiding in the session page

Even tried using leptonX theme

Hi there,

found another bug, when using the public site with top menu:

Uncaught TypeError: Cannot read properties of undefined (reading 'querySelector') at e.updateSelected (lepton-x.bundle.min.js?_v=638695393640000000:2:73734) at e.updateAllSelected (lepton-x.bundle.min.js?_v=638695393640000000:2:91910) at e.withPersistedValue (lepton-x.bundle.min.js?_v=638695393640000000:2:91260) at Function.create (lepton-x.bundle.min.js?_v=638695393640000000:2:75931) at t.createSettingGroups (lepton-x.bundle.min.js?_v=638695393640000000:2:77120) at lepton-x.bundle.min.js?_v=638695393640000000:2:76821 at NodeList.forEach (<anonymous>) at lepton-x.bundle.min.js?_v=638695393640000000:2:77884 at lepton-x.bundle.min.js?_v=638695393640000000:2:52556 at Map.forEach (<anonymous>)

I guess this error is more related to Lepton X 4.0.3 but since thats the version used for abp 9.0.2 i report it here.

This error results in Language-Switch not being added to the general settings and also the selected language is missing next to the settings gear.

I already debugged the js code a bit and it seems that the error occurs because the js script tries to load stuff for the containerWidth settings group. But since its an error inside the leptonx bundle i think its more productive that you guys check this further out and fix it.

I am facing the same bug after upgrading to 9.0.X. Locally, I was able to fix it by adding lepton-x.bundle.min.js to the folder \Themes\LeptonX\Global\top-menu\js But when i deployed to AZURE, it didnt have any effect. Please let us know when this will be fixed or any workarounds

thank you!

Overall Goal :

Enabled users to self register + Assign a **new **database for each new user.


Problem I was calling var result = await base.OnPostAsync(); which registers a user in the host. a new tenant with a admin role with the same email address was the duplicate email.

Solution : I override the post async and remove the RegisterLocalUserAsync which solved the duplicate email. I dont want to store this user in the host


Current Problem: Attached the current code. https://drive.google.com/file/d/10yTLcz5QeiZ8Gy7FulbGPP5YzeOC_2UZ/view?usp=sharing Attached the current logs : https://drive.google.com/file/d/1eu1ukcUamo0Lrd-50aNEpkmWE6YdzlxK/view?usp=sharing

this is needed for a TENANT with a new database to be created. ** await _dbSchemaMigrator.MigrateAsync();**

This line is needed for the USERNAME to have the same name entered in the registration OR else the default admin name "admin" is used. ** await _dataSeeder.SeedAsync(new DataSeedContext(tenant.Id) .WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, Input.EmailAddress) .WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, Input.Password) .WithProperty(IdentityDataSeedContributor.AdminUserNamePropertyName, Input.UserName)); **

If I use both, I get a transient failure to ABP permission grants. How do i resolve the issue?

this is happening every time during the initial registration. Lets say, you have USER100, it will say USER100 is duplicate because the migration are running twice.

DUPS EMAIL ISSUE

I am spinning up a new database with a new user. this is the only user in the whole database. then its says duplicate email found.

  • Problem // its called the base.onpostsync() -- which adds the user.
  • Then we are creating a new tenant with an admin user with the same email and id. I think that' s the problem.
  • Do you agree?

What code changes do you suggest? we want to make use of all the code in the base class except make sure to have a seperate db for each user.

This is closely related to the https://abp.io/support/questions/8116/Change-default-admin-name-to-the-provided-USER-NAME-when-creating-a-new-tenant

It didnt completely resolve the problem.

Good News Code below

  • Create a new tenant with a new database (works)
  • Create a ADMIN USER with a USER NAME provided in the registration page (works)

However, 2 problems **

  1. Duplicate Email Issue However, I see this error in the logs --> https://drive.google.com/file/d/1-fctzIxKqW5zSgSvLGbjCdaWh31mvWAV/view?usp=sharing

  2. Once we resolve #1, how do we assign custom permission to the admin user. This will be customer facing app - so i dont want the admin to meddle with CMS KIT, View Security Logs, Audit Logs etc. I just want him to look at APP pages that i created + Add new users if he wants to. Is that possible. The code below for permission is a simple prototype I was trying - but even that didnt work.

PLEASE Help.

*** removing import statement for brevity ******

namespace Janvika.Finxplorer.Blazor.Pages.Account
{
    public class CustomRegisterModel : RegisterModel
    {
        private readonly ITenantAppService _tenantAppService;
        private readonly IConfiguration _configuration;
        private readonly IdentityUserManager _identityUserManager;
        private readonly IUnitOfWorkManager _unitOfWorkManager;
        private readonly ILogger<CustomRegisterModel> _logger;
        private readonly IFinxplorerDbSchemaMigrator _dbSchemaMigrator;
        private readonly ICurrentTenant _currentTenant;
        private readonly IDataSeeder _dataSeeder;
        private readonly IIdentityRoleRepository _roleRepository;
        private readonly IPermissionManager _permissionManager;

        public CustomRegisterModel(
            IAuthenticationSchemeProvider schemeProvider,
            IOptions<AbpAccountOptions> accountOptions,
            IAccountExternalProviderAppService accountExternalProviderAppService,
            ICurrentPrincipalAccessor currentPrincipalAccessor,
            IHttpClientFactory httpClientFactory,
            ITenantAppService tenantAppService,
            IConfiguration configuration,
            IdentityUserManager identityUserManager,
            IUnitOfWorkManager unitOfWorkManager,
            ILogger<CustomRegisterModel> logger,
            IFinxplorerDbSchemaMigrator dbSchemaMigrator,
            ICurrentTenant currentTenant,
            IDataSeeder dataSeeder,
            IIdentityRoleRepository roleRepository,
            IPermissionManager permissionManager
        ) : base(schemeProvider, accountOptions, accountExternalProviderAppService, currentPrincipalAccessor, httpClientFactory)
        {
            _tenantAppService = tenantAppService;
            _configuration = configuration;
            _identityUserManager = identityUserManager;
            _unitOfWorkManager = unitOfWorkManager;
            _logger = logger;
            _dbSchemaMigrator = dbSchemaMigrator;
            _currentTenant = currentTenant;
            _dataSeeder = dataSeeder;
            _roleRepository = roleRepository;
            _permissionManager = permissionManager;
        }

        public override async Task<IActionResult> OnPostAsync()
        {

               // Call the base OnPostAsync method to retain the base functionality
            var result = await base.OnPostAsync();
            if (!ModelState.IsValid)
            {
                return result;
            }

            try
            {
                var tenantName = $"{Input.UserName}-dedicated-tenant";
                var defaultConnectionString = _configuration.GetConnectionString("Default");

                if (string.IsNullOrEmpty(defaultConnectionString))
                {
                    throw new Exception("Default connection string is not configured in app settings.");
                }

                // Create the database for the new tenant
                var tenantConnectionString = CreateTenantSpecificConnectionString(defaultConnectionString, tenantName);

                SaasTenantDto tenant;
                using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))
                {
                    var tenantCreateDto = new SaasTenantCreateDto
                    {
                        Name = tenantName,
                        AdminEmailAddress = Input.EmailAddress,
                        AdminPassword = Input.Password,
                        ConnectionStrings = new SaasTenantConnectionStringsDto
                        {
                            Default = tenantConnectionString
                        }
                    };

                    tenant = await _tenantAppService.CreateAsync(tenantCreateDto);

                    await MigrateAndSeedTenantDatabaseAsync(tenant.Id);

                    // Assign permissions to the existing admin role
                    await AssignPermissionsToAdminRoleAsync(tenant.Id);

                    await uow.CompleteAsync();
                }


                    // Migrate and seed the tenant database
              

            

                // Redirect to the login page
                return RedirectToPage("./Login");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An error occurred during registration");
                // Redirect to the login page
                return RedirectToPage("./Login");
            }
        }

        private string CreateTenantSpecificConnectionString(string defaultConnectionString, string tenantName)
        {
            var builder = new NpgsqlConnectionStringBuilder(defaultConnectionString);
            builder.Database = tenantName;
            return builder.ConnectionString;
        }

        private async Task MigrateAndSeedTenantDatabaseAsync(Guid tenantId)
        {
            using (_currentTenant.Change(tenantId))
            {
              await _dbSchemaMigrator.MigrateAsync();

              
              await _dataSeeder.SeedAsync(
                    new DataSeedContext(tenantId)
                    .WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, Input.EmailAddress)
                    .WithProperty(IdentityDataSeedContributor.AdminUserNamePropertyName, Input.UserName)
                    .WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, Input.Password)
                    
                    );
        
           
            
            }
        }

        private async Task AssignPermissionsToAdminRoleAsync(Guid tenantId)
        {
            using (_currentTenant.Change(tenantId))
            {
                // Find the existing admin role
                var adminRole = await _roleRepository.FindByNormalizedNameAsync("ADMIN");
                if (adminRole == null)
                {
                    throw new Exception("Admin role not found.");
                }

         
                var permissions = new[] { "My.CUSTOM" }; // permission names
                foreach (var permission in permissions)
                {
                    await _permissionManager.SetForRoleAsync(adminRole.Name, permission, true);
                }

                // Assign admin role to the registered user
                var user = await _identityUserManager.FindByEmailAsync(Input.EmailAddress);
                if (user != null)
                {
                    await _identityUserManager.AddToRoleAsync(user, adminRole.Name);
                }
            }
        }
    }
}

yes that worked like a charm! thanks you.

Its working when you are adding text, however the button is not rendering. do you have any ideas? I have not added any custom code. Just copy paste the same code from the source module.

Showing 1 to 10 of 21 entries
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.3.0-preview. Updated on April 16, 2025, 12:13