Open Closed

Remove email confirmation email on new user registration #5326


User avatar
0
csykes created
  • ABP Framework version: v7.0.2
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): Blazor Server Tiered
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

We have a Blazor Server application that uses Azure Active Directory OpenId for user registration and login:

When the user registers for the first time, they receive this email:

If they click the link, they are taken back to the application and an "Invalid token" error is shown:

We don't want our new users to receive this email. How can we stop it from being sent?


1 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can try this:

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(IAccountAppService)]
    public class MyAccountAppService : AccountAppService
    {
        public MyAccountAppService(IdentityUserManager userManager, IAccountEmailer accountEmailer, IAccountPhoneService phoneService, IIdentityRoleRepository roleRepository, IdentitySecurityLogManager identitySecurityLogManager, IBlobContainer<AccountProfilePictureContainer> accountProfilePictureContainer, ISettingManager settingManager, IOptions<IdentityOptions> identityOptions, IIdentitySecurityLogRepository securityLogRepository, IApplicationInfoAccessor applicationInfoAccessor) : base(userManager, accountEmailer, phoneService, roleRepository, identitySecurityLogManager, accountProfilePictureContainer, settingManager, identityOptions, securityLogRepository, applicationInfoAccessor)
        {
        }
    
        public override 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();
    
            return ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);
        }
    }
    
Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11