mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-12 10:30:47 +01:00
Fixing bug on password not being cleared
This commit is contained in:
parent
1da2cedffd
commit
70c2fc0a9e
2 changed files with 19 additions and 5 deletions
|
@ -4104,6 +4104,9 @@ namespace BTCPayServer.Tests
|
|||
var admin = tester.NewAccount();
|
||||
await admin.GrantAccessAsync(true);
|
||||
var adminClient = await admin.CreateClient(Policies.Unrestricted);
|
||||
// validate that clear email settings will not throw an error
|
||||
await adminClient.UpdateServerEmailSettings(new ServerEmailSettingsData());
|
||||
|
||||
var data = new ServerEmailSettingsData
|
||||
{
|
||||
From = "admin@admin.com",
|
||||
|
@ -4130,6 +4133,11 @@ namespace BTCPayServer.Tests
|
|||
From = "invalid"
|
||||
}));
|
||||
|
||||
// check that clear server email settings works
|
||||
await adminClient.UpdateServerEmailSettings(new ServerEmailSettingsData());
|
||||
var clearedSettings = await adminClient.GetServerEmailSettings();
|
||||
Assert.Equal(JsonConvert.SerializeObject(new EmailSettingsData { PasswordSet = false }), JsonConvert.SerializeObject(clearedSettings));
|
||||
|
||||
// NOTE: This email test fails silently in EmailSender.cs#31, can't test, but leaving for the future as reminder
|
||||
//await adminClient.SendEmail(admin.StoreId,
|
||||
// new SendEmailRequest { Body = "lol", Subject = "subj", Email = "to@example.org" });
|
||||
|
@ -4144,8 +4152,8 @@ namespace BTCPayServer.Tests
|
|||
var admin = tester.NewAccount();
|
||||
await admin.GrantAccessAsync(true);
|
||||
var adminClient = await admin.CreateClient(Policies.Unrestricted);
|
||||
await adminClient.UpdateStoreEmailSettings(admin.StoreId,
|
||||
new EmailSettingsData());
|
||||
// validate that clear email settings will not throw an error
|
||||
await adminClient.UpdateStoreEmailSettings(admin.StoreId, new EmailSettingsData());
|
||||
|
||||
var data = new EmailSettingsData
|
||||
{
|
||||
|
@ -4165,6 +4173,11 @@ namespace BTCPayServer.Tests
|
|||
async () => await adminClient.UpdateStoreEmailSettings(admin.StoreId,
|
||||
new EmailSettingsData { From = "invalid" }));
|
||||
|
||||
// clear store email settings
|
||||
await adminClient.UpdateStoreEmailSettings(admin.StoreId, new EmailSettingsData());
|
||||
var clearedSettings = await adminClient.GetStoreEmailSettings(admin.StoreId);
|
||||
Assert.Equal(JsonConvert.SerializeObject(new EmailSettingsData { PasswordSet = false }), JsonConvert.SerializeObject(clearedSettings));
|
||||
|
||||
await adminClient.SendEmail(admin.StoreId,
|
||||
new SendEmailRequest { Body = "lol", Subject = "subj", Email = "to@example.org" });
|
||||
}
|
||||
|
|
|
@ -36,8 +36,9 @@ namespace BTCPayServer.Services.Mails
|
|||
Server = data.Server,
|
||||
Port = data.Port,
|
||||
Login = data.Login,
|
||||
// Retaining the password if it exists and was not provided in request
|
||||
Password = string.IsNullOrEmpty(data.Password) ? existingPassword : data.Password,
|
||||
// If login was provided but password was not, use the existing password from database
|
||||
Password = !string.IsNullOrEmpty(data.Login) && string.IsNullOrEmpty(data.Password) ?
|
||||
existingPassword : data.Password,
|
||||
From = data.From,
|
||||
DisableCertificateCheck = data.DisableCertificateCheck
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue