diff --git a/src/DigitalData.EmailProfiler.Application/Common/Dtos/EmailAccountDto.cs b/src/DigitalData.EmailProfiler.Application/Common/Dtos/EmailAccountDto.cs index dad8154..73dc892 100644 --- a/src/DigitalData.EmailProfiler.Application/Common/Dtos/EmailAccountDto.cs +++ b/src/DigitalData.EmailProfiler.Application/Common/Dtos/EmailAccountDto.cs @@ -5,19 +5,15 @@ namespace DigitalData.EmailProfiler.Application.Common.Dtos; /// public class EmailAccountDto { - public int Id { get; set; } - public string AccountName { get; set; } = string.Empty; - public string ImapServer { get; set; } = string.Empty; - public int ImapPort { get; set; } - public bool ImapUseSsl { get; set; } - public string SmtpServer { get; set; } = string.Empty; - public int SmtpPort { get; set; } - public bool SmtpUseSsl { get; set; } - public string Username { get; set; } = string.Empty; + public string Username { get; set; } = null!; + public string? EncryptedPassword { get; set; } + + public string SmtpServer { get; set; } = null!; + + public int SmtpPort { get; set; } + + public bool SmtpUseSsl { get; set; } + public bool UseOAuth2 { get; set; } - public string? TenantId { get; set; } - public string? ClientId { get; set; } - public string? EncryptedClientSecret { get; set; } - public bool IsActive { get; set; } } diff --git a/src/DigitalData.EmailProfiler.Infrastructure/DependencyInjection.cs b/src/DigitalData.EmailProfiler.Infrastructure/DependencyInjection.cs index 999e544..42230a3 100644 --- a/src/DigitalData.EmailProfiler.Infrastructure/DependencyInjection.cs +++ b/src/DigitalData.EmailProfiler.Infrastructure/DependencyInjection.cs @@ -2,6 +2,7 @@ using DigitalData.EmailProfiler.Application.Common.Interfaces; using DigitalData.EmailProfiler.Infrastructure.Messaging; using DigitalData.EmailProfiler.Infrastructure.Queue; using DigitalData.EmailProfiler.Infrastructure.Services; +using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -43,9 +44,9 @@ public static class DependencyInjection services.AddHostedService(); // --- Data Protection (for encryption) --- - services.AddDataProtection(); - // .PersistKeysToFileSystem(new DirectoryInfo(@"C:\ProgramData\EmailProfiler\Keys")) - // .SetApplicationName("EmailProfiler"); + services.AddDataProtection() + .PersistKeysToFileSystem(new DirectoryInfo(@"C:\ProgramData\EmailService\Keys")) + .SetApplicationName("EmailProfiler"); return services; } diff --git a/src/DigitalData.EmailProfiler.Infrastructure/Services/DataProtectionEncryptionService.cs b/src/DigitalData.EmailProfiler.Infrastructure/Services/DataProtectionEncryptionService.cs index 6f170ee..7cfa5a1 100644 --- a/src/DigitalData.EmailProfiler.Infrastructure/Services/DataProtectionEncryptionService.cs +++ b/src/DigitalData.EmailProfiler.Infrastructure/Services/DataProtectionEncryptionService.cs @@ -13,25 +13,11 @@ public class DataProtectionEncryptionService(IDataProtectionProvider Provider) : public string Encrypt(string plainText) { - if (string.IsNullOrEmpty(plainText)) - return string.Empty; - return Protector.Protect(plainText); } public string Decrypt(string cipherText) { - if (string.IsNullOrEmpty(cipherText)) - return string.Empty; - - try - { - return Protector.Unprotect(cipherText); - } - catch (Exception) - { - // If decryption fails, return empty (corrupt data or wrong key) - return string.Empty; - } + return Protector.Unprotect(cipherText); } }