Open Closed

Send the same message when an account exists or not in the recovery password #4488


User avatar
0
peyman@debtrak.com created

ABP Framework version: v5.3.4

UI type: Angular

DB provider: EF Core

Tiered (MVC) or Identity Server Separated (Angular): yes Hi .we want for security in Forgot password , flow and messages be the same when an account exist or not exist, how can I do that? and i want to know how override SendPasswordResetCodeAsync and config it.

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

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

    Hi,

    You can try to override the SendPasswordResetCodeAsync method to handle the exception.

    For example:

    [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) : base(userManager, accountEmailer, phoneService, roleRepository, identitySecurityLogManager, accountProfilePictureContainer, settingManager, identityOptions, securityLogRepository)
       {
       }
       public override async Task SendPasswordResetCodeAsync(SendPasswordResetCodeDto input)
       {
           try
           {
               var user = await GetUserByEmail(input.Email);
               var resetToken = await UserManager.GeneratePasswordResetTokenAsync(user);
               await AccountEmailer.SendPasswordResetLinkAsync(user, resetToken, input.AppName, input.ReturnUrl, input.ReturnUrlHash);
           }
           catch (Exception e)
           {
               throw new UserFriendlyException("custom message");
           }
    
       }
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 21, 2026, 06:18
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.