Misc Bugfixes (#2832)

This commit is contained in:
Joe Milazzo 2024-04-07 12:29:29 -05:00 committed by GitHub
parent 57fb2d01b9
commit 0277f8f4c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 172 additions and 179 deletions

View file

@ -51,16 +51,19 @@ public class EmailService : IEmailService
private readonly IUnitOfWork _unitOfWork;
private readonly IDirectoryService _directoryService;
private readonly IHostEnvironment _environment;
private readonly ILocalizationService _localizationService;
private const string TemplatePath = @"{0}.html";
private const string LocalHost = "localhost:4200";
public EmailService(ILogger<EmailService> logger, IUnitOfWork unitOfWork, IDirectoryService directoryService, IHostEnvironment environment)
public EmailService(ILogger<EmailService> logger, IUnitOfWork unitOfWork, IDirectoryService directoryService,
IHostEnvironment environment, ILocalizationService localizationService)
{
_logger = logger;
_unitOfWork = unitOfWork;
_directoryService = directoryService;
_environment = environment;
_localizationService = localizationService;
}
/// <summary>
@ -75,9 +78,18 @@ public class EmailService : IEmailService
};
var settings = await _unitOfWork.SettingsRepository.GetSettingsDtoAsync();
if (!IsValidEmail(adminEmail) || !settings.IsEmailSetup())
if (!IsValidEmail(adminEmail))
{
result.ErrorMessage = "You need to fill in more information in settings and ensure your account has a valid email to send a test email";
var defaultAdmin = await _unitOfWork.UserRepository.GetDefaultAdminUser();
result.ErrorMessage = await _localizationService.Translate(defaultAdmin.Id, "account-email-invalid");
result.Successful = false;
return result;
}
if (!settings.IsEmailSetup())
{
var defaultAdmin = await _unitOfWork.UserRepository.GetDefaultAdminUser();
result.ErrorMessage = await _localizationService.Translate(defaultAdmin.Id, "email-settings-invalid");
result.Successful = false;
return result;
}