Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Tenancy name is not valid! #9812


User avatar
0
alfar_re created

Hi,

I'm trying to change the registration page to accept a mobile number as the tenant name but I get the error

Tenancy name is not valid!

What might be the problem.

-ASP.NET -MVC -.NET CORE -Latest ABP Framework according to Zero 9.2


14 Answer(s)
  • User Avatar
    0
    zony created
    Support Team

    Hi alfar_re, This is because in AbpTenantManager, the tenant name needs to be verified. You can override the ValidateTenancyName method to change the validation rules. default validation rule:

    /// <summary>
    /// "^[a-zA-Z][a-zA-Z0-9_-]{1,}$".
    /// </summary>
    public const string TenancyNameRegex = "^[a-zA-Z][a-zA-Z0-9_-]{1,}$";
    
    public class YourTenantManager<TTenant, TUser> : AbpTenantManager<TTenant, TUser> where TTenant : AbpTenant<TUser>
        where TUser : AbpUserBase
    {
        public YourTenantManager(IRepository<TTenant> tenantRepository, IRepository<TenantFeatureSetting, long> tenantFeatureRepository, AbpEditionManager editionManager, IAbpZeroFeatureValueStore featureValueStore) : base(tenantRepository, tenantFeatureRepository, editionManager, featureValueStore)
        {
        }
    
        protected override void ValidateTenancyName(string tenancyName)
        {
            // Your code.
            // base.ValidateTenancyName(tenancyName);
        }
    }
    

    Then use the Configuration.Replace method to replace the component.

  • User Avatar
    0
    alfar_re created

    Hi @zony,

    This is well noted. I changed my TenancyNameRegex to the desired one but I still get the error. Kindly show me how and where to do the Configuration.Replace

    Thanks.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @alfar_re

    Do you get this error on the Client Side ? If so, could you share your Regex and tenancy name you try ?

  • User Avatar
    0
    alfar_re created

    Hi @ismcagdas,

    Yes I get this error on the client side.

    My regex: ^[0-9]{10}$ My TenancyName: local 10 digit mobile number

  • User Avatar
    0
    alfar_re created

    Hi @ismcagdas,

    Can I get a resolution for this? It has been many days.

  • User Avatar
    0
    zony created
    Support Team

    Hi alfar_re, As far as I know, when the client only creates tenants and registers tenants, regex verification is performed. So, can you share a question Demo and send it to my email?([email protected])

  • User Avatar
    0
    alfar_re created

    Hi @zony,

    I see.

    I'm thinking I can autogenerate my tenancy names then collect a mobile number from the user and use the mobile number as the username. My goal is to have users login using their mobile numbers. Would that work?

  • User Avatar
    0
    zony created
    Support Team

    Hi alfar_re, This is feasible. You only need to use the mobile phone number to construct a super administrator account when each tenant is created.

  • User Avatar
    0
    alfar_re created

    Hi @zony,

    Great. Let me try that.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @alfar_re

    Did that work for you ?

  • User Avatar
    0
    alfar_re created

    Hi @ismcagdas,

    Yes it did. Only one problem remaining. When a new tenant registers, the registration goes through well but on login, they get the error;

    Current user did not login to the application

  • User Avatar
    0
    musa.demir created

    Hi @alfar_re

    Can you please share related part of log.txt file.

  • User Avatar
    0
    alfar_re created

    Hello @musa.demir,

    It seems there is a problem with some browsers. I tried a different browser and got a different error. The error was based on the user not having sufficient rights. How do I make the new user the admin with all available rights?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @alfar_re

    Normally, this line https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Core/MultiTenancy/TenantManager.cs#L132 grants all permissions to newly created Tenant's admin role.