Refactor password handling in EmailAccountDto
Replaced the `EncryptedPassword` property in `EmailAccountDto` with `Password` and `PasswordEncrypted` to support both plain text and encrypted passwords. Updated `LimilabsEmailService` to use the new properties, checking the `PasswordEncrypted` flag to determine whether decryption is needed.
This commit is contained in:
@@ -7,7 +7,9 @@ public class EmailAccountDto
|
|||||||
{
|
{
|
||||||
public string Username { get; set; } = null!;
|
public string Username { get; set; } = null!;
|
||||||
|
|
||||||
public string? EncryptedPassword { get; set; }
|
public string Password { get; set; } = null!;
|
||||||
|
|
||||||
|
public bool PasswordEncrypted { get; set; } = false;
|
||||||
|
|
||||||
public string SmtpServer { get; set; } = null!;
|
public string SmtpServer { get; set; } = null!;
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ public class LimilabsEmailService(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var password = encryptionService.Decrypt(_smtpAccount.EncryptedPassword!);
|
var password = _smtpAccount.PasswordEncrypted ? encryptionService.Decrypt(_smtpAccount.Password) : _smtpAccount.Password;
|
||||||
|
|
||||||
smtp.Login(_smtpAccount.Username, password);
|
smtp.Login(_smtpAccount.Username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user