Harden password reset and email send flows
This commit is contained in:
@@ -19,13 +19,15 @@ namespace JobTrackerApi.Controllers
|
||||
private readonly ISummarizerService _summarizer;
|
||||
private readonly IAppEmailSender _email;
|
||||
private readonly UserManager<ApplicationUser> _users;
|
||||
private readonly ILogger<JobApplicationsController> _logger;
|
||||
|
||||
public JobApplicationsController(JobTrackerContext db, ISummarizerService summarizer, IAppEmailSender email, UserManager<ApplicationUser> users)
|
||||
public JobApplicationsController(JobTrackerContext db, ISummarizerService summarizer, IAppEmailSender email, UserManager<ApplicationUser> users, ILogger<JobApplicationsController> logger)
|
||||
{
|
||||
_db = db;
|
||||
_summarizer = summarizer;
|
||||
_email = email;
|
||||
_users = users;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
private string? CurrentUserId =>
|
||||
@@ -2492,7 +2494,15 @@ Job description:
|
||||
var toEmail = (request.ToEmail ?? job.Company?.RecruiterEmail ?? string.Empty).Trim();
|
||||
if (string.IsNullOrWhiteSpace(toEmail)) return BadRequest("Recipient email is required.");
|
||||
|
||||
await _email.SendAsync(toEmail, request.Subject.Trim(), request.Body.Trim(), cancellationToken);
|
||||
try
|
||||
{
|
||||
await _email.SendAsync(toEmail, request.Subject.Trim(), request.Body.Trim(), cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Failed to send follow-up email for job {JobId} to {Email}", id, toEmail);
|
||||
return Problem(statusCode: StatusCodes.Status503ServiceUnavailable, title: "Email delivery unavailable", detail: "Follow-up email could not be sent right now. Please try again later.");
|
||||
}
|
||||
|
||||
_db.Correspondences.Add(new Correspondence
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user