Open Closed

Customizing tenant & user registration and adding roles #1350


User avatar
0
sergei.gorlovetsky@gmail.com created
  • ABP Framework version: v4.3.0
  • UI type: Angular
  • DB provider: MongoDB
  • Tiered (MVC) or Identity Server Separated (Angular): yes

We want to customize tenant and user registration with roles as below

  1. For tenant registration we want to suggest user the subdomain name based on the email id user entering and send an invite email, also while creating new tenant want to add more static roles(staff, client) like admin
  2. For user registration we have an entity called client and we want to add "Invite" functionality in that, which will send an email to user with registration link, on clicking of that link user can register himself, userid will be updated to client entity and user will assign a fixed role.

We need help deciding where we should be writing this logic, as we have tiered architecture (separate identity server), we should create custom registration pages on angular side or identity side? And what is the best practice for adding more roles to new tenants and users?


2 Answer(s)
  • User Avatar
    0
    alper created
    Support Team Director

    1- You need to customize the register component to ask user "subdomain" name. and you need to modify the backend to send this data. The register action URL is /api/account/register . it's in the Account.Pro module. \Volo.Abp.Account.Pro.Public.Application\Volo\Abp\Account\AccountAppService.cs

    This is the register method of AccountAppService. You can override this method and add a Subdomain property to RegisterDto. check out https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities

            public virtual async Task<IdentityUserDto> RegisterAsync(RegisterDto input)
            {
                await CheckSelfRegistrationAsync();
    
                if (await UseCaptchaOnRegistration())
                {
                    var reCaptchaValidator = await RecaptchaValidatorFactory.CreateAsync();
                    await reCaptchaValidator.ValidateAsync(input.CaptchaResponse);
                }
    
                await IdentityOptions.SetAsync();
    
                var user = new IdentityUser(GuidGenerator.Create(), input.UserName, input.EmailAddress, CurrentTenant.Id);
    
                input.MapExtraPropertiesTo(user);
    
                (await UserManager.CreateAsync(user, input.Password)).CheckErrors();
                (await UserManager.AddDefaultRolesAsync(user)).CheckErrors();
    
                if (!user.EmailConfirmed)
                {
                    await SendEmailConfirmationTokenAsync(user, input.AppName, input.ReturnUrl, input.ReturnUrlHash);
                }
    
                return ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);
            }
    
    
    
    
    

    https://community.abp.io/articles/how-to-add-custom-property-to-the-user-entity-6ggxiddr

    https://gist.github.com/mehmet-erim/b93759e97bd3f43bf98aca29bdd1fe66 https://support.abp.io/QA/Questions/160/How-to-customize-an-ABP-project

    2- You can check out this topic https://support.abp.io/QA/Questions/1340/How-to-removedisable-validation-for-existing-DTO-object . In this topic user is trying to remove validation from an existing DTO. It's similar to your requirement. You are trying to replace an appservice with your own modified one.

  • User Avatar
    0
    ServiceBot created
    Support Team Automatic process manager

    This question has been automatically marked as stale because it has not had recent activity.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11