Added the check before sending mail when adding application access to employee

This commit is contained in:
ashutosh.nehete 2025-10-01 10:10:01 +05:30
parent 824381bb49
commit 7659eadd00

View File

@ -1182,10 +1182,13 @@ namespace MarcoBMS.Services.Controllers
// Prepare reset link sender helper // Prepare reset link sender helper
private async Task SendResetIfApplicableAsync(ApplicationUser u, string firstName) private async Task SendResetIfApplicableAsync(ApplicationUser u, string firstName)
{ {
var token = await _userManager.GeneratePasswordResetTokenAsync(u); if (!string.IsNullOrWhiteSpace(u.Email))
var resetLink = $"{_configuration["AppSettings:WebFrontendUrl"]}/reset-password?token={WebUtility.UrlEncode(token)}"; {
await _emailSender.SendResetPasswordEmailOnRegister(u.Email ?? "", firstName, resetLink); var token = await _userManager.GeneratePasswordResetTokenAsync(u);
_logger.LogInfo("Reset password email queued. Email={Email}", u.Email ?? ""); var resetLink = $"{_configuration["AppSettings:WebFrontendUrl"]}/reset-password?token={WebUtility.UrlEncode(token)}";
await _emailSender.SendResetPasswordEmailOnRegister(u.Email, firstName, resetLink);
_logger.LogInfo("Reset password email queued. Email={Email}", u.Email);
}
} }
} }
} }